Oracle Row-Level Locking ↔ Distributed Transactions: Lock Release Timing
0 reputation · 18 Aug 2022, 01:58 UTC
Locking Behavior in XA Transactions
Oracle Database utilizes Interested Transaction Lists (ITL) in data block headers to manage row-level locking. While standard local transactions release locks immediately upon a COMMIT or ROLLBACK, distributed transactions utilizing the XA standard involve a two-phase commit (2PC) process.
In a distributed environment, a transaction may enter a 'prepared' state where the local resource manager has agreed to commit but is awaiting the final global decision from the transaction manager. This creates a window of uncertainty regarding the exact moment row-level locks are released to other concurrent sessions.
When a second session attempts to access a locked row using SELECT ... FOR UPDATE NOWAIT, the behavior is typically a prompt ORA-00054 error. However, the latency between the local phase-one commit and the final global commit can lead to unpredictable lock durations.
Interoperability Questions
- Does the row-level lock persist throughout the entire duration of the 'prepared' state in an XA transaction until the final commit signal is received?
- How does the
NOWAITmechanism differentiate between a standard active transaction lock and a lock held by a distributed transaction in a prepared state?