1
votes

Am I right in the following?

Transaction in Serializable IsolationLevel sets read locks for select statements. There are two transactions selecting some range. Both get read locks. But then first transaction updates or adds new value inside the selected range and commits. What will happen with the second transaction? Will it fail if tries to update or add value inside selected range after first transaction has commited?

2

2 Answers

2
votes

You don't say RDBMS so I am assuming a simple locking scheme with S and X locks. You say.

Transaction in Serializable IsolationLevel sets read locks for select statements. There are two transactions selecting some range. Both get read locks.

But then first transaction updates or adds new value inside the selected range and commits.

This wouldn't be possible if the second transaction already has a read lock on the range. It would have to wait until the second transaction released its lock. If the second transaction also attempted to update the range then deadlock would result.

0
votes

yes, the second transaction will fail because the second transaction will only see datas commited before the begin of the transaction.