postgresql/src/backend
Andres Freund ee3f8d3d3a pgstat: Bring up pgstat in BaseInit() to fix uninitialized use of pgstat by AV.
Previously pgstat_initialize() was called in InitPostgres() and
AuxiliaryProcessMain(). As it turns out there was at least one case where we
reported stats before pgstat_initialize() was called, see
AutoVacWorkerMain()'s intentionally early call to pgstat_report_autovac().

This turns out to not be a problem with the current pgstat implementation as
pgstat_initialize() only registers a shutdown callback. But in the shared
memory based stats implementation we are working towards pgstat_initialize()
has to do more work.

After b406478b87 BaseInit() is a central place where initialization shared by
normal backends and auxiliary backends can be put. Obviously BaseInit() is
called before InitPostgres() registers ShutdownPostgres. Previously
ShutdownPostgres was the first before_shmem_exit callback, now that's commonly
pgstats. That should be fine.

Previously pgstat_initialize() was not called in bootstrap mode, but there
does not appear to be a need for that. It's now done unconditionally.

To detect future issues like this, assertions are added to a few places
verifying that the pgstat subsystem is initialized and not yet shut down.

Author: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/20210405092914.mmxqe7j56lsjfsej@alap3.anarazel.de
Discussion: https://postgr.es/m/20210802164124.ufo5buo4apl6yuvs@alap3.anarazel.de
2021-08-06 19:05:59 -07:00
..
access pgstat: split reporting/fetching of bgwriter and checkpointer stats. 2021-08-04 19:16:04 -07:00
bootstrap process startup: Always call Init[Auxiliary]Process() before BaseInit(). 2021-08-05 15:36:59 -07:00
catalog Add missing message punctuation 2021-08-06 22:11:28 +02:00
commands Add prepare API support for streaming transactions in logical replication. 2021-08-04 07:47:06 +05:30
executor Fix oversight in commit 1ec7fca859. 2021-08-02 12:45:00 +09:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Clarify some comments making use of leetspeak term "up2date" 2021-07-28 10:31:24 +09:00
lib Fix typo in comment 2021-04-20 14:35:16 +02:00
libpq Add more sanity checks in SASL exchanges 2021-07-10 21:45:28 +09:00
main process startup: Centralize pgwin32_signal_initialize() calls. 2021-08-05 12:36:06 -07:00
nodes Track a Bitmapset of non-pruned partitions in RelOptInfo 2021-08-03 11:47:24 +12:00
optimizer Allow ordered partition scans in more cases 2021-08-03 12:25:52 +12:00
parser Don't elide casting to typmod -1. 2021-08-06 17:32:54 -04:00
partitioning Allow ordered partition scans in more cases 2021-08-03 12:25:52 +12:00
po Translation updates 2021-06-21 12:33:50 +02:00
port Initial pgindent and pgperltidy run for v14. 2021-05-12 13:14:10 -04:00
postmaster pgstat: Bring up pgstat in BaseInit() to fix uninitialized use of pgstat by AV. 2021-08-06 19:05:59 -07:00
regex Fix performance issue in new regex match-all detection code. 2021-05-03 11:42:31 -04:00
replication Remove unused argument "txn" in maybe_send_schema(). 2021-08-05 17:49:51 +09:00
rewrite Use l*_node() family of functions where appropriate 2021-07-19 08:20:24 +02:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Error message refactoring 2021-06-27 09:41:16 +02:00
storage process startup: Always call Init[Auxiliary]Process() before BaseInit(). 2021-08-05 15:36:59 -07:00
tcop process startup: Always call Init[Auxiliary]Process() before BaseInit(). 2021-08-05 15:36:59 -07:00
tsearch Improve various places that double the size of a buffer 2021-07-01 15:29:06 +12:00
utils pgstat: Bring up pgstat in BaseInit() to fix uninitialized use of pgstat by AV. 2021-08-06 19:05:59 -07:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Translation updates 2021-05-10 14:36:21 +02:00