postgresql/src/include/utils
Andres Freund 8b1dccd37c pgstat: scaffolding for transactional stats creation / drop.
One problematic part of the current statistics collector design is that there
is no reliable way of getting rid of statistics entries. Because of that
pgstat_vacuum_stat() (called by [auto-]vacuum) matches all stats for the
current database with the catalog contents and tries to drop now-superfluous
entries. That's quite expensive. What's worse, it doesn't work on physical
replicas, despite physical replicas collection statistics entries.

This commit introduces infrastructure to create / drop statistics entries
transactionally, together with the underlying catalog objects (functions,
relations, subscriptions). pgstat_xact.c maintains a list of stats entries
created / dropped transactionally in the current transaction. To ensure the
removal of statistics entries is durable dropped statistics entries are
included in commit / abort (and prepare) records, which also ensures that
stats entries are dropped on standbys.

Statistics entries created separately from creating the underlying catalog
object (e.g. when stats were previously lost due to an immediate restart)
are *not* WAL logged. However that can only happen outside of the transaction
creating the catalog object, so it does not lead to "leaked" statistics
entries.

For this to work, functions creating / dropping functions / relations /
subscriptions need to call into pgstat. For subscriptions this was already
done when dropping subscriptions, via pgstat_report_subscription_drop() (now
renamed to pgstat_drop_subscription()).

This commit does not actually drop stats yet, it just provides the
infrastructure. It is however a largely independent piece of infrastructure,
so committing it separately makes sense.

Bumps XLOG_PAGE_MAGIC.

Author: Andres Freund <andres@anarazel.de>
Reviewed-By: Thomas Munro <thomas.munro@gmail.com>
Reviewed-By: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/20220303021600.hs34ghqcw6zcokdh@alap3.anarazel.de
2022-04-06 18:27:52 -07:00
..
.gitignore Revert "Add gitignore entries for jsonpath_gram.h" 2019-03-23 00:19:34 +01:00
acl.h Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
aclchk_internal.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
array.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
arrayaccess.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
ascii.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
attoptcache.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
backend_progress.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
backend_status.h pgstat: stats collector references in comments. 2022-04-06 13:56:06 -07:00
builtins.h Remove pg_atoi() 2022-02-15 07:44:26 +01:00
bytea.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
cash.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
catcache.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
combocid.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
date.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
datetime.h Fix overflow hazards in interval input and output conversions. 2022-04-02 16:12:29 -04:00
datum.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
dsa.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
dynahash.h Fix various typos, grammar and code style in comments and docs 2022-01-25 09:40:04 +09:00
elog.h Introduce log_destination=jsonlog 2022-01-17 10:16:53 +09:00
evtcache.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
expandeddatum.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
expandedrecord.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
float.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
fmgrtab.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
formatting.h SQL/JSON query functions 2022-03-29 16:57:13 -04:00
freepage.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
geo_decls.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
guc.h Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
guc_tables.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
help_config.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
hsearch.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
index_selfuncs.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
inet.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
inval.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
json.h SQL JSON functions 2022-03-30 16:30:37 -04:00
jsonb.h SQL JSON functions 2022-03-30 16:30:37 -04:00
jsonfuncs.h SQL/JSON query functions 2022-03-29 16:57:13 -04:00
jsonpath.h JSON_TABLE 2022-04-04 16:03:47 -04:00
logtape.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
lsyscache.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
memdebug.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
memutils.h Improve the generation memory allocator 2022-04-04 20:53:13 +12:00
multirangetypes.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
numeric.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
old_snapshot.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
palloc.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
partcache.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_crc.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_locale.h Fix global ICU collations for ICU < 54 2022-03-20 10:21:45 +01:00
pg_lsn.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pg_rusage.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pgstat_internal.h pgstat: scaffolding for transactional stats creation / drop. 2022-04-06 18:27:52 -07:00
pidfile.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
plancache.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
portal.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
ps_status.h Refactor ps_status.c API 2020-03-11 16:38:31 +01:00
queryenvironment.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
queryjumble.h Add compute_query_id = regress 2022-02-22 10:22:15 +09:00
rangetypes.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
regproc.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
rel.h Remove obsolete comment 2022-04-02 07:41:12 +02:00
relcache.h Allow specifying row filters for logical replication of tables. 2022-02-22 08:11:50 +05:30
relfilenodemap.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
relmapper.h Add new block-by-block strategy for CREATE DATABASE. 2022-03-29 11:48:36 -04:00
relptr.h Suppress compiler warning in relptr_store(). 2022-03-26 14:30:09 -04:00
reltrigger.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
resowner.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
resowner_private.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
rls.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
ruleutils.h Add public ruleutils.c entry point to deparse a Query. 2022-03-28 11:19:37 -04:00
sampling.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
selfuncs.h Optimize order of GROUP BY keys 2022-03-31 01:13:33 +02:00
sharedtuplestore.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
snapmgr.h Assert in init_toast_snapshot() that some snapshot registered or active. 2022-02-21 08:58:29 -08:00
snapshot.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
sortsupport.h Specialize tuplesort routines for different kinds of abbreviated keys 2022-04-02 15:22:25 +07:00
spccache.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
syscache.h Allow granting SET and ALTER SYSTEM privileges on GUC parameters. 2022-04-06 13:24:33 -04:00
timeout.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
timestamp.h Fix overflow hazards in interval input and output conversions. 2022-04-02 16:12:29 -04:00
tuplesort.h Use Generation memory contexts to store tuples in sorts 2022-04-04 22:52:35 +12:00
tuplestore.h Remove all traces of tuplestore_donestoring() in the C code 2022-02-17 09:52:02 +09:00
typcache.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
tzparser.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
uuid.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
varbit.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
varlena.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
wait_event.h Add new block-by-block strategy for CREATE DATABASE. 2022-03-29 11:48:36 -04:00
xid8.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
xml.h Update copyright for 2022 2022-01-07 19:04:57 -05:00