Skip to content

Commit 73cfd50

Browse files
alterego655Commitfest Bot
authored andcommitted
Add WAIT_EVENT_XACT_COMPLETE to XactLockTableWait functions
XactLockTableWait and ConditionalXactLockTableWait previously lacked a specific wait event, making backend states less transparent. This commit introduces WAIT_EVENT_XACT_COMPLETE, which both functions now report to pg_stat_activity during their sleep phases, enhancing visibility.
1 parent bca9a19 commit 73cfd50

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/backend/storage/lmgr/lmgr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,9 @@ XactLockTableWait(TransactionId xid, Relation rel, ItemPointer ctid,
719719
if (!first)
720720
{
721721
CHECK_FOR_INTERRUPTS();
722+
pgstat_report_wait_start(WAIT_EVENT_XACT_COMPLETE);
722723
pg_usleep(1000L);
724+
pgstat_report_wait_end();
723725
}
724726
first = false;
725727
xid = SubTransGetTopmostTransaction(xid);
@@ -762,7 +764,9 @@ ConditionalXactLockTableWait(TransactionId xid, bool logLockFailure)
762764
if (!first)
763765
{
764766
CHECK_FOR_INTERRUPTS();
767+
pgstat_report_wait_start(WAIT_EVENT_XACT_COMPLETE);
765768
pg_usleep(1000L);
769+
pgstat_report_wait_end();
766770
}
767771
first = false;
768772
xid = SubTransGetTopmostTransaction(xid);

src/backend/utils/activity/wait_event_names.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ WAL_BUFFER_INIT "Waiting on WAL buffer to be initialized."
160160
WAL_RECEIVER_EXIT "Waiting for the WAL receiver to exit."
161161
WAL_RECEIVER_WAIT_START "Waiting for startup process to send initial data for streaming replication."
162162
WAL_SUMMARY_READY "Waiting for a new WAL summary to be generated."
163+
XACT_COMPLETE "Waiting for a transaction to complete."
163164
XACT_GROUP_UPDATE "Waiting for the group leader to update transaction status at transaction end."
164165

165166
ABI_compatibility:
@@ -423,7 +424,7 @@ extend "Waiting to extend a relation."
423424
frozenid "Waiting to update <structname>pg_database</structname>.<structfield>datfrozenxid</structfield> and <structname>pg_database</structname>.<structfield>datminmxid</structfield>."
424425
page "Waiting to acquire a lock on a page of a relation."
425426
tuple "Waiting to acquire a lock on a tuple."
426-
transactionid "Waiting for a transaction to finish."
427+
transactionid "Waiting to acquire a transaction ID lock; see <xref linkend="transaction-id"/>."
427428
virtualxid "Waiting to acquire a virtual transaction ID lock; see <xref linkend="transaction-id"/>."
428429
spectoken "Waiting to acquire a speculative insertion lock."
429430
object "Waiting to acquire a lock on a non-relation database object."

0 commit comments

Comments
 (0)