0001-Add-WAIT_EVENT_XACT_DONE.patch
application/x-patch
Filename: 0001-Add-WAIT_EVENT_XACT_DONE.patch
Type: application/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch 0001
Subject: Add WAIT_EVENT_XACT_DONE
| File | + | − |
|---|---|---|
| src/backend/storage/lmgr/lmgr.c | 4 | 0 |
| src/backend/utils/activity/wait_event_names.txt | 1 | 0 |
From a99ad22010d5b779b7c24c981ca1a025cc1cad3b Mon Sep 17 00:00:00 2001
From: alterego665 <824662526@qq.com>
Date: Wed, 4 Jun 2025 16:37:31 +0800
Subject: [PATCH] Add WAIT_EVENT_XACT_DONE
XactLockTableWait and ConditionalXactLockTableWait previously lacked a
specific wait event, making backend states less transparent. This commit
introduces WAIT_EVENT_XACT_DONE, which both functions now report to
pg_stat_activity during their sleep phases, enhancing visibility.
---
src/backend/storage/lmgr/lmgr.c | 4 ++++
src/backend/utils/activity/wait_event_names.txt | 1 +
2 files changed, 5 insertions(+)
diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c
index 3f6bf70bd3c..a35de2c497a 100644
--- a/src/backend/storage/lmgr/lmgr.c
+++ b/src/backend/storage/lmgr/lmgr.c
@@ -719,7 +719,9 @@ XactLockTableWait(TransactionId xid, Relation rel, ItemPointer ctid,
if (!first)
{
CHECK_FOR_INTERRUPTS();
+ pgstat_report_wait_start(WAIT_EVENT_XACT_DONE);
pg_usleep(1000L);
+ pgstat_report_wait_end();
}
first = false;
xid = SubTransGetTopmostTransaction(xid);
@@ -762,7 +764,9 @@ ConditionalXactLockTableWait(TransactionId xid, bool logLockFailure)
if (!first)
{
CHECK_FOR_INTERRUPTS();
+ pgstat_report_wait_start(WAIT_EVENT_XACT_DONE);
pg_usleep(1000L);
+ pgstat_report_wait_end();
}
first = false;
xid = SubTransGetTopmostTransaction(xid);
diff --git a/src/backend/utils/activity/wait_event_names.txt b/src/backend/utils/activity/wait_event_names.txt
index 4da68312b5f..3da08b853c3 100644
--- a/src/backend/utils/activity/wait_event_names.txt
+++ b/src/backend/utils/activity/wait_event_names.txt
@@ -161,6 +161,7 @@ WAL_RECEIVER_EXIT "Waiting for the WAL receiver to exit."
WAL_RECEIVER_WAIT_START "Waiting for startup process to send initial data for streaming replication."
WAL_SUMMARY_READY "Waiting for a new WAL summary to be generated."
XACT_GROUP_UPDATE "Waiting for the group leader to update transaction status at transaction end."
+XACT_DONE "Waiting for a transaction to commit or abort."
ABI_compatibility:
--
2.48.1