v2-0001-Add-a-new-wait-state-and-use-it-when-sending-data.patch
application/octet-stream
Filename: v2-0001-Add-a-new-wait-state-and-use-it-when-sending-data.patch
Type: application/octet-stream
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 v2-0001
Subject: Add a new wait state and use it when sending data in the apply worker.
| File | + | − |
|---|---|---|
| doc/src/sgml/monitoring.sgml | 5 | 0 |
| src/backend/replication/logical/applyparallelworker.c | 2 | 1 |
| src/backend/utils/activity/wait_event.c | 3 | 0 |
| src/include/utils/wait_event.h | 1 | 0 |
From e5006bbc8761f76a2d9a057726c2000fbc797dc4 Mon Sep 17 00:00:00 2001
From: Hou Zhijie <houzj.fnst@cn.fujitsu.com>
Date: Fri, 10 Feb 2023 10:04:39 +0800
Subject: [PATCH v2] Add a new wait state and use it when sending data in the
apply worker.
d9d7fe6 reuse existing wait event when sending data in apply worker. But we
should have invent a new wait state if we are waiting at a new place, so fix
this.
---
doc/src/sgml/monitoring.sgml | 5 +++++
src/backend/replication/logical/applyparallelworker.c | 3 ++-
src/backend/utils/activity/wait_event.c | 3 +++
src/include/utils/wait_event.h | 1 +
4 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index dca50707ad..b0b997f092 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -1740,6 +1740,11 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
<entry>Waiting for other Parallel Hash participants to finish inserting
tuples into new buckets.</entry>
</row>
+ <row>
+ <entry><literal>LogicalApplySendData</literal></entry>
+ <entry>Waiting for a logical replication leader apply process to send
+ data to a parallel apply process.</entry>
+ </row>
<row>
<entry><literal>LogicalParallelApplyStateChange</literal></entry>
<entry>Waiting for a logical replication parallel apply process to change
diff --git a/src/backend/replication/logical/applyparallelworker.c b/src/backend/replication/logical/applyparallelworker.c
index da437e0bc3..4518683779 100644
--- a/src/backend/replication/logical/applyparallelworker.c
+++ b/src/backend/replication/logical/applyparallelworker.c
@@ -1181,7 +1181,8 @@ pa_send_data(ParallelApplyWorkerInfo *winfo, Size nbytes, const void *data)
/* Wait before retrying. */
rc = WaitLatch(MyLatch,
WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
- SHM_SEND_RETRY_INTERVAL_MS, WAIT_EVENT_MQ_SEND);
+ SHM_SEND_RETRY_INTERVAL_MS,
+ WAIT_EVENT_LOGICAL_APPLY_SEND_DATA);
if (rc & WL_LATCH_SET)
{
diff --git a/src/backend/utils/activity/wait_event.c b/src/backend/utils/activity/wait_event.c
index 6e4599278c..cb99cc6339 100644
--- a/src/backend/utils/activity/wait_event.c
+++ b/src/backend/utils/activity/wait_event.c
@@ -391,6 +391,9 @@ pgstat_get_wait_ipc(WaitEventIPC w)
case WAIT_EVENT_HASH_GROW_BUCKETS_REINSERT:
event_name = "HashGrowBucketsReinsert";
break;
+ case WAIT_EVENT_LOGICAL_APPLY_SEND_DATA:
+ event_name = "LogicalApplySendData";
+ break;
case WAIT_EVENT_LOGICAL_PARALLEL_APPLY_STATE_CHANGE:
event_name = "LogicalParallelApplyStateChange";
break;
diff --git a/src/include/utils/wait_event.h b/src/include/utils/wait_event.h
index 6cacd6edaf..9ab23e1c4a 100644
--- a/src/include/utils/wait_event.h
+++ b/src/include/utils/wait_event.h
@@ -106,6 +106,7 @@ typedef enum
WAIT_EVENT_HASH_GROW_BUCKETS_ALLOCATE,
WAIT_EVENT_HASH_GROW_BUCKETS_ELECT,
WAIT_EVENT_HASH_GROW_BUCKETS_REINSERT,
+ WAIT_EVENT_LOGICAL_APPLY_SEND_DATA,
WAIT_EVENT_LOGICAL_PARALLEL_APPLY_STATE_CHANGE,
WAIT_EVENT_LOGICAL_SYNC_DATA,
WAIT_EVENT_LOGICAL_SYNC_STATE_CHANGE,
--
2.39.1.windows.1