A transaction executes these 2 statements with the READ COMMITTED isolation
SELECT * FROM CATS WHERE ID=1 FOR UPDATE SKIP LOCKED
SELECT * FROM CATS WHERE ID=1
The first query returns the ID 1 row. I wonder if the second query will always return values equals to the result of the first query?
My concerns are the following
I have read the following question and the associated articles: Force Oracle to return TOP N rows with SKIP LOCKED.
If I understand correctly, Oracle first computes the result set, it opens the cursor and then for each row, skip the row if the row is already locked. Without SKIP LOCKED
the result set is locked when the cursor is opened.
Is this correct?
If yes, given a READ COMMITTED isolation:
A transaction
T1
executes this statementSELECT * FROM CATS WHERE ID=1 FOR UPDATE SKIP LOCKED
A concurrent transaction
T2
updates the same result setUPDATE CATS SET CATS.AGE = 10 WHERE CATS.ID = 1
I wonder given the below scenario if T2 can update a row before the row is locked by T1:
- T1: Oracle computes the result set
- T2: Oracle updates the same result set and COMMIT
- T1: Oracle opens the cursor
- T1: Oracle for each row, skips the row if the row is already locked
Is it possible?