C
C#2mo ago
Core

Isolation level for reading a row only once

Hi, I need to select the first row from a table where a column value is equal to false and also modify it to true. This means, if many request come at the same time (they do), no 2 SELECT statements should get the same row. I am sure a distributed lock would solve the problem, but I was wondering if a transaction isolation level would be enough. Would Serializable isolation level be ideal for this use case?
No description
3 Replies
boiled goose
boiled goose2mo ago
i would bet the combination of "many requests" and "using database for locking" wouldn't end well, but i could be wrong
Core
Core2mo ago
Thanks, then I will go with a distributed lock
boiled goose
boiled goose2mo ago
you can still benchmark it, especially if you can use an in-memory table