The specification for the Repeatable-Read isolation level defines that a transaction with this IL will prevent other transactions from updating any rows that this transaction has read until this transaction has completed. Thus, repeatable reads are guaranteed.
Consider the following order of operations for two concurrent transactions T1 and T2, both using repeatable read IL:
- T1: Read row
- T2: Read row
- T1: Update row
- T2: Update row
I think that the update in step 3 would violate the specification for the isolation level, since T2 would read a different value if it read the row again. The converse can be said for the update in step 4.
So, what different options are available for RDBMSs in general resolve this conflict? More specifically, how is this handled in SQL Server 2017+? Will this result in a deadlock since neither transaction can complete its operations? Or would one transaction be rolled back? I've seen that Lost Updates are prevented in SQL Server. What does this mean for the resolution of this specific case?
I have perused the answers to these questions: Repeatable read and lock compatibility table Repeatable Read - am I understanding this right? repeatable read and second lost updates issue MySQL Repeatable Read isolation level and Lost Update phenomena
And although the last one asks a similar question but doesn't include any specific info about how RDBMSs which prevent lost updates for txs with this isolation level handle this case.