tengiz wrote:So you do agree that the 'true' SERIALIZABLE, by itself, is not adequate in this situation since it leads to a dead-lock almost immediatetely and therefore is not 'true' SERIALIZABLE' ?
No, I don't. Proper transaction isolation prevents anomalies.
I thought we'd agreed a long while ago to use this informal definition:
"A schedule is serializable if it is equivalent to some serial schedule."
... and not talk in terms of phenomena/anomalies.
If we use the above definition instead of anomalies and such, then the 'true' SERIALIZABLE is not really SERIALIZABLE since some legal schedules can fail.
tengiz wrote: Update locking hint in our case, in turn, prevents deadlocks literally serializing the execution (that's why you'd better put code like this at the very end of the transaction).
Let's be more precise with our words. The updlock hint does not serialize the transactions it makes them literally *serial* (non-concurrent).
tengiz wrote: So, updlock here is really just an optimization and does not affect the correctness of the program – and you don't have to put it in there: with or without the locking hint you'll never get inconsistent results.
I would not call it optimization but rather a crutch that helps the invalid ('true' SERIALIZABLE) walk. Without the hint, in my simple example, the second session managed to run only 2-3 transactions before the dead-lock occured. Yeah, I did not get inconsistent results, I got hardly any.
Still waiting for a single-sql-no-hints solution ;)
VC