#include "common/blkreftable.h"
#include "libpq/pqsignal.h"
#include "miscadmin.h"
+#include "pgstat.h"
#include "postmaster/auxprocess.h"
#include "postmaster/interrupt.h"
#include "postmaster/walsummarizer.h"
sleep_quanta -= pages_read_since_last_sleep;
}
+ /* Report pending statistics to the cumulative stats system. */
+ pgstat_report_wal(false);
+
/* OK, now sleep. */
(void) WaitLatch(MyLatch,
WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
*/
bool requestReply = false;
+ /*
+ * Report pending statistics to the cumulative stats
+ * system. This location is useful for the report as it
+ * is not within a tight loop in the WAL receiver, to
+ * avoid bloating pgstats with requests, while also making
+ * sure that the reports happen each time a status update
+ * is sent.
+ */
+ pgstat_report_wal(false);
+
/*
* Check if time since last receive from primary has
* reached the configured limit.
*/
no_temp_rel = bktype == B_AUTOVAC_LAUNCHER || bktype == B_BG_WRITER ||
bktype == B_CHECKPOINTER || bktype == B_AUTOVAC_WORKER ||
- bktype == B_STANDALONE_BACKEND || bktype == B_STARTUP;
+ bktype == B_STANDALONE_BACKEND || bktype == B_STARTUP ||
+ bktype == B_WAL_SUMMARIZER || bktype == B_WAL_WRITER ||
+ bktype == B_WAL_RECEIVER;
if (no_temp_rel && io_context == IOCONTEXT_NORMAL &&
io_object == IOOBJECT_TEMP_RELATION)
return false;
+ /*
+ * Some BackendTypes only perform IO under IOOBJECT_WAL, hence exclude all
+ * rows for all the other objects for these.
+ */
+ if ((bktype == B_WAL_SUMMARIZER || bktype == B_WAL_RECEIVER ||
+ bktype == B_WAL_WRITER) && io_object != IOOBJECT_WAL)
+ return false;
+
/*
* Some BackendTypes do not currently perform any IO in certain
* IOContexts, and, while it may not be inherently incorrect for them to
EOM
ok($result, "WAL summarization caught up after insert");
+# The WAL summarizer should have generated some IO statistics.
+my $stats_reads = $node1->safe_psql(
+ 'postgres',
+ qq{SELECT sum(reads) > 0 FROM pg_stat_io
+ WHERE backend_type = 'walsummarizer' AND object = 'wal'});
+is($stats_reads, 't', "WAL summarizer generates statistics for WAL reads");
+
# Find the highest LSN that is summarized on disk.
my $summarized_lsn = $node1->safe_psql('postgres', <<EOM);
SELECT MAX(end_lsn) AS summarized_lsn FROM pg_available_wal_summaries()
$node_standby_2->enable_streaming($node_primary);
$node_standby_2->reload;
+# The WAL receiver should have generated some IO statistics.
+my $stats_reads = $node_standby_1->safe_psql(
+ 'postgres',
+ qq{SELECT sum(writes) > 0 FROM pg_stat_io
+ WHERE backend_type = 'walreceiver' AND object = 'wal'});
+is($stats_reads, 't', "WAL receiver generates statistics for WAL writes");
+
# be sure do not streaming from cascade
$node_standby_1->stop;