pgsql: Force to send remaining WAL stats to the stats collector at walw

From: Fujii Masao <fujii(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Force to send remaining WAL stats to the stats collector at walw
Date: 2021-03-12 04:30:45
Message-ID: E1lKZRl-00006h-IE@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Force to send remaining WAL stats to the stats collector at walwriter exit.

In walwriter's main loop, WAL stats message is only sent if enough time
has passed since last one was sent to reach PGSTAT_STAT_INTERVAL msecs.
This is necessary to avoid overloading to the stats collector. But this
can cause recent WAL stats to be unsent when walwriter exits.

To ensure that all the WAL stats are sent, this commit makes walwriter
force to send remaining WAL stats to the collector when it exits because
of shutdown request. Note that those remaining WAL stats can still be
unsent when walwriter exits with non-zero exit code (e.g., FATAL error).
This is OK because that walwriter exit leads to server crash and
subsequent recovery discards all the stats. So there is no need to send
remaining stats in that case.

Author: Masahiro Ikeda
Reviewed-by: Fujii Masao
Discussion: https://postgr.es/m/0509ad67b585a5b86a83d445dfa75392@oss.nttdata.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/33394ee6f2433d3cc7785428a77cc9a813254df7

Modified Files
--------------
src/backend/postmaster/walwriter.c | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2021-03-12 05:24:01 pgsql: Send statistics collected during shutdown checkpoint to the stat
Previous Message Thomas Munro 2021-03-12 02:36:43 pgsql: Minor modernization for README.barrier.