Commit 139eb967 authored by Peter Eisentraut's avatar Peter Eisentraut

Report statistics in logical replication workers

Author: Stas Kelvich <s.kelvich@postgrespro.ru>
Author: Petr Jelinek <petr.jelinek@2ndquadrant.com>
Reported-by: default avatarFujii Masao <masao.fujii@gmail.com>
parent 67c2def1
......@@ -769,9 +769,10 @@ allow_immediate_pgstat_restart(void)
/* ----------
* pgstat_report_stat() -
*
* Called from tcop/postgres.c to send the so far collected per-table
* and function usage statistics to the collector. Note that this is
* called only when not within a transaction, so it is fair to use
* Must be called by processes that performs DML: tcop/postgres.c, logical
* receiver processes, SPI worker, etc. to send the so far collected
* per-table and function usage statistics to the collector. Note that this
* is called only when not within a transaction, so it is fair to use
* transaction stop time as an approximation of current time.
* ----------
*/
......
......@@ -114,9 +114,15 @@ StringInfo copybuf = NULL;
static void pg_attribute_noreturn()
finish_sync_worker(void)
{
/* Commit any outstanding transaction. */
/*
* Commit any outstanding transaction. This is the usual case, unless
* there was nothing to do for the table.
*/
if (IsTransactionState())
{
CommitTransactionCommand();
pgstat_report_stat(false);
}
/* And flush all writes. */
XLogFlush(GetXLogWriteRecPtr());
......
......@@ -462,6 +462,7 @@ apply_handle_commit(StringInfo s)
/* Process any tables that are being synchronized in parallel. */
process_syncing_tables(commit_data.end_lsn);
pgstat_report_stat(false);
pgstat_report_activity(STATE_IDLE, NULL);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment