Reputation: 211
I was wondering what happens to a transactions that got blocked by another transaction?
It will best to work through an example, say I have two transactions - T1 and T2 and following scenario:
T1 ........................................................ T2
Lock DB object
Read Q ..................................................Lock Q (T2 is blocked)
Write Q Unlock Q
So does the T2 is un-blocked after T1 is done or is it forever lost? I used to think that T2 was sent into a wait queue and waits there for its turn.
Thank you anyone who would clarify this concept to me :)
Upvotes: 0
Views: 89
Reputation: 206659
There are two common things that happen in this case:
UPDATE
or LOCK TABLE
statement issued with the NOWAIT
option.)Having T2 "lost forever" would be a bug in the database engine.
An interesting read about Oracle's locking strategies: How Oracle Locks Data. (That whole chapter, Data Concurrency and Consistency, is interesting if you're studying these database aspects. Note that these details are highly database dependent. What you read there will not apply directly to SQL Server, DB2 or MySQL for instance.)
Upvotes: 1