Quantcast
Channel: User Mark - Stack Overflow
Viewing all articles
Browse latest Browse all 44

Answer by Mark for Etags used in RESTful APIs are still susceptible to race conditions

$
0
0

You are right that you can still get race conditions if the 'check last etag' and 'make the change' aren't in one atomic operation.

In essence, if your server itself has a race condition, sending etags to the client won't help with that.

You already mentioned a good way to achieve this atomicity:

The only fool-proof solution I can think of is to also make the database perform the check, in the update query for example.

You could do something else, like using a mutex lock. Or using an architecture where two threads cannot deal with the same data.

But the database check seems good to me. What you describe about ORM checks might be an addition for better error messages, but is not by itself sufficient as you found.


Viewing all articles
Browse latest Browse all 44

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>