postgresql/src/include
Tom Lane 6fea65508a Tighten ComputeXidHorizons' handling of walsenders.
ComputeXidHorizons (nee GetOldestXmin) thought that it could identify
walsenders by checking for proc->databaseId == 0.  Perhaps that was
safe when the code was written, but it's been wrong at least since
autovacuum was invented.  Background processes that aren't connected
to any particular database, such as the autovacuum launcher and
logical replication launcher, look like that too.

This imprecision is harmful because when such a process advertises an
xmin, the result is to hold back dead-tuple cleanup in all databases,
though it'd be sufficient to hold it back in shared catalogs (which
are the only relations such a process can access).  Aside from being
generally inefficient, this has recently been seen to cause regression
test failures in the buildfarm, as a consequence of the logical
replication launcher's startup transaction preventing VACUUM from
marking pages of a user table as all-visible.

We only want that global hold-back effect for the case where a
walsender is advertising a hot standby feedback xmin.  Therefore,
invent a new PGPROC flag that says that a process' xmin should be
considered globally, and check that instead of using the incorrect
databaseId == 0 test.  Currently only a walsender sets that flag,
and only if it is not connected to any particular database.  (This is
for bug-compatibility with the undocumented behavior of the existing
code, namely that feedback sent by a client who has connected to a
particular database would not be applied globally.  I'm not sure this
is a great definition; however, such a client is capable of issuing
plain SQL commands, and I don't think we want xmins advertised for
such commands to be applied globally.  Perhaps this could do with
refinement later.)

While at it, I rewrote the comment in ComputeXidHorizons, and
re-ordered the commented-upon if-tests, to make them match up
for intelligibility's sake.

This is arguably a back-patchable bug fix, but given the lack of
complaints I think it prudent to let it age awhile in HEAD first.

Discussion: https://postgr.es/m/1346227.1649887693@sss.pgh.pa.us
2022-04-15 17:50:05 -04:00
..
access Prevent access to no-longer-pinned buffer in heapam_tuple_lock(). 2022-04-13 13:35:07 -04:00
bootstrap Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
catalog Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
commands Remove "recheck" argument from check_index_is_clusterable() 2022-04-13 15:32:35 +09:00
common Remove not-very-useful early checks of __pg_log_level in logging.h. 2022-04-12 13:25:29 -04:00
datatype Fix overflow hazards in interval input and output conversions. 2022-04-02 16:12:29 -04:00
executor Track I/O timing for temporary file blocks in EXPLAIN (BUFFERS) 2022-04-08 11:27:21 +09:00
fe_utils Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
foreign Update copyright for 2022 2022-01-07 19:04:57 -05:00
jit Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
lib Improve frontend error logging style. 2022-04-08 14:55:14 -04:00
libpq Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
mb Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
nodes Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
optimizer Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
parser Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
partitioning Refactor and cleanup runtime partition prune code a little 2022-04-05 11:46:48 +02:00
port Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
portability Update copyright for 2022 2022-01-07 19:04:57 -05:00
postmaster Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
regex Update copyright for 2022 2022-01-07 19:04:57 -05:00
replication Add missing spaces after single-line comments 2022-04-14 09:28:56 +12:00
rewrite Update copyright for 2022 2022-01-07 19:04:57 -05:00
snowball Update copyright for 2022 2022-01-07 19:04:57 -05:00
statistics Add stxdinherit flag to pg_statistic_ext_data 2022-01-16 13:38:01 +01:00
storage Tighten ComputeXidHorizons' handling of walsenders. 2022-04-15 17:50:05 -04:00
tcop Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
tsearch Add missing spaces after single-line comments 2022-04-14 09:28:56 +12:00
utils Fix various typos and spelling mistakes in code comments 2022-04-11 20:49:41 +12:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
fmgr.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
funcapi.h Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
getaddrinfo.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
getopt_long.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
Makefile Build in some knowledge about foreign-key relationships in the catalogs. 2021-02-02 17:11:55 -05:00
miscadmin.h Revert the addition of GetMaxBackends() and related stuff. 2022-04-12 14:45:23 -04:00
pg_config.h.in libpq: Allow IP address SANs in server certificates 2022-04-01 15:51:23 +02:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Fix DROP {DATABASE,TABLESPACE} on Windows. 2022-02-12 10:21:23 +13:00
pg_getopt.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
pg_trace.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pgstat.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
pgtar.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
pgtime.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
port.h Clean up messy API for src/port/thread.c. 2022-01-11 13:46:20 -05:00
postgres.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
rusagestub.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
windowapi.h Update copyright for 2022 2022-01-07 19:04:57 -05:00