|
|
|
|
|
by aphyr
2476 days ago
|
|
All those should be possible; you just might not observe the state of the counter as it was a few milliseconds(?) ago, rather than what it might be right now. If you're dealing with extremely frequent updates where the chances of observing that sort of anomaly are more common, chances are the precise value of the counter doesn't matter so much, and an occasional off-by-one or off-by-two isn't the end of the world. YMMV, of course. :) |
|
did you mean 'might observe' instead of 'might not'? stale read would result in the older value being read.
i believe the anomaly would then occur depending on how close the 2 events are in time, regardless of frequency.
in that case, precise counts can be needed even with low frequency. say you are a restaurant with 1 burger left. 2 folks order the same time, but you decrement the count by 1 only.
also anything involving monetary values, you definitely don't want to read stale values ever.