Oracle DB Transactions — Read Skew

Transaction T1 reads x, and then a second transaction T2 updates x and y to new values and commits . If now T1 reads y, it may see an inconsistent state, and therefore produce an inconsistent state as output.

r1[x]…w2[x]…w2[y]…c2…r1[y]…(c1 or a1)

💡 How to read the shorthand notations? w means write, r means read, number(1 or 2) indicates transaction id, c means commit and a means abort/rollback

Example

Image for post
Image for post
Read Skew occurs in “READ COMMITTED” isolation level in Oracle
Image for post
Image for post
Read Skew does not occur in “SERIALIZABLE” isolation level in Oracle

Read skew is avoided in Oracle DB, provided there is a parent-child relationship between the tables which were read at different point-in-time.

💡Serializable isolation level in Oracle is actually a “Snapshot Isolation”

Transaction 1

Transaction 2

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store