v1-0001-Fix-stats-reporting-delays-in-parallel-apply-work.patch
application/octet-stream
Filename: v1-0001-Fix-stats-reporting-delays-in-parallel-apply-work.patch
Type: application/octet-stream
Part: 1
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 v1-0001
Subject: Fix stats reporting delays in parallel apply worker
| File | + | − |
|---|---|---|
| src/backend/replication/logical/applyparallelworker.c | 9 | 0 |
From d6df6255fdc49e26e65637826358de2a7ce37bc1 Mon Sep 17 00:00:00 2001 From: Zhijie Hou <houzj.fnst@fujitsu.com> Date: Wed, 15 Apr 2026 17:30:03 +0800 Subject: [PATCH v1 1/2] Fix stats reporting delays in parallel apply worker Parallel apply workers currently do not flush statistics while idle in their main loop. This can cause stats from the last processed transaction to be arbitrarily delayed, especially when there are long gaps between streamed transactions. Fix this by forcing a stats report when the worker is idle in the main loop, ensuring timely visibility of accumulated statistics. --- src/backend/replication/logical/applyparallelworker.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/backend/replication/logical/applyparallelworker.c b/src/backend/replication/logical/applyparallelworker.c index 798e8d85b3e..aaa21a5a94a 100644 --- a/src/backend/replication/logical/applyparallelworker.c +++ b/src/backend/replication/logical/applyparallelworker.c @@ -815,6 +815,15 @@ LogicalParallelApplyLoop(shm_mq_handle *mqh) if (rc & WL_LATCH_SET) ResetLatch(MyLatch); + + /* + * Force stats reporting to avoid long delays. There can be long + * idle gaps before the leader assigns the next transaction, and + * the only opportunity to report stats during such gaps is + * here. + */ + if ((rc & WL_TIMEOUT) && !IsTransactionState()) + pgstat_report_stat(true); } } else -- 2.53.0.windows.2