mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Setup error context callback for transaction lock waits
With this in place, a session blocking behind another one because of tuple locks will get a context line mentioning the relation name, tuple TID, and operation being done on tuple. For example: LOG: process 11367 still waiting for ShareLock on transaction 717 after 1000.108 ms DETAIL: Process holding the lock: 11366. Wait queue: 11367. CONTEXT: while updating tuple (0,2) in relation "foo" STATEMENT: UPDATE foo SET value = 3; Most usefully, the new line is displayed by log entries due to log_lock_waits, although of course it will be printed by any other log message as well. Author: Christian Kruse, some tweaks by Álvaro Herrera Reviewed-by: Amit Kapila, Andres Freund, Tom Lane, Robert Haas
This commit is contained in:
@@ -2295,7 +2295,9 @@ IndexBuildHeapScan(Relation heapRelation,
|
||||
* Must drop the lock on the buffer before we wait
|
||||
*/
|
||||
LockBuffer(scan->rs_cbuf, BUFFER_LOCK_UNLOCK);
|
||||
XactLockTableWait(xwait);
|
||||
XactLockTableWait(xwait, heapRelation,
|
||||
&heapTuple->t_data->t_ctid,
|
||||
XLTW_InsertIndexUnique);
|
||||
goto recheck;
|
||||
}
|
||||
}
|
||||
@@ -2341,7 +2343,9 @@ IndexBuildHeapScan(Relation heapRelation,
|
||||
* Must drop the lock on the buffer before we wait
|
||||
*/
|
||||
LockBuffer(scan->rs_cbuf, BUFFER_LOCK_UNLOCK);
|
||||
XactLockTableWait(xwait);
|
||||
XactLockTableWait(xwait, heapRelation,
|
||||
&heapTuple->t_data->t_ctid,
|
||||
XLTW_InsertIndexUnique);
|
||||
goto recheck;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user