Hacker News new | ask | show | jobs
by Thaxll 480 days ago
This is not a thread safety issue though, this is a transaction problem.
2 comments

It’s absolutely a thread safety issue. It’s not a data race, but it’s a race condition and can very much cause unexpected behaviour e.g. out of bounds error even though on its face it has the correct preconditions.
Wrapping these 2 statements in a transaction will not solve this particular issue unless the transactions are run sequentially.