Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 139eb96

Browse files
committed
Report statistics in logical replication workers
Author: Stas Kelvich <s.kelvich@postgrespro.ru> Author: Petr Jelinek <petr.jelinek@2ndquadrant.com> Reported-by: Fujii Masao <masao.fujii@gmail.com>
1 parent 67c2def commit 139eb96

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/backend/postmaster/pgstat.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -769,9 +769,10 @@ allow_immediate_pgstat_restart(void)
769769
/* ----------
770770
* pgstat_report_stat() -
771771
*
772-
* Called from tcop/postgres.c to send the so far collected per-table
773-
* and function usage statistics to the collector. Note that this is
774-
* called only when not within a transaction, so it is fair to use
772+
* Must be called by processes that performs DML: tcop/postgres.c, logical
773+
* receiver processes, SPI worker, etc. to send the so far collected
774+
* per-table and function usage statistics to the collector. Note that this
775+
* is called only when not within a transaction, so it is fair to use
775776
* transaction stop time as an approximation of current time.
776777
* ----------
777778
*/

src/backend/replication/logical/tablesync.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,15 @@ StringInfo copybuf = NULL;
114114
static void pg_attribute_noreturn()
115115
finish_sync_worker(void)
116116
{
117-
/* Commit any outstanding transaction. */
117+
/*
118+
* Commit any outstanding transaction. This is the usual case, unless
119+
* there was nothing to do for the table.
120+
*/
118121
if (IsTransactionState())
122+
{
119123
CommitTransactionCommand();
124+
pgstat_report_stat(false);
125+
}
120126

121127
/* And flush all writes. */
122128
XLogFlush(GetXLogWriteRecPtr());

src/backend/replication/logical/worker.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ apply_handle_commit(StringInfo s)
462462
/* Process any tables that are being synchronized in parallel. */
463463
process_syncing_tables(commit_data.end_lsn);
464464

465+
pgstat_report_stat(false);
465466
pgstat_report_activity(STATE_IDLE, NULL);
466467
}
467468

0 commit comments

Comments
 (0)