4 ms·
simple case of this is an increment operation the programmer has written an incorrect function that does a SQL read, parses a value and then does an update. It
by awinter-py 7y ago
simple case of this is an increment operation
the programmer has written an incorrect function that does a SQL read, parses a value and then does an update. It doesn't use a transaction (i.e. no synchronization) so this is unsafe to use in parallel.
and someone else uses their function without reading carefully, spinning off two invocations without reading carefully and awaiting them both
I suspect you'll agree this is incorrect in that the value will be incremented once instead of twice.
If you don't call this a race condition, what do you call it?
- zAy0LfpBZLC8mAC 7y agoYour original scenario was one with deterministic execution order, this one as far as I can tell is not ... so, how is this example relevant to the discussion?
- awinter-py 7y agoif you make some assumptions about how long IO takes and how the systems order IO, this overlapping-increment example will have a deterministic order and still be wrong every time (increment once instead of twice). The assumptions are that op1 and op2 are started in order and that your database replies in the order received.
- zAy0LfpBZLC8mAC 7y ago> if you make some assumptions about how long IO takes and how the systems order IO, this overlapping-increment example will have a deterministic order and still be wrong every time (increment once instead of twice). So? Is every piece of code that gives the wrong result a race condition?