pgsql: Fix multixact backwards-compatibility with CHECKPOINT race condi - Mailing list pgsql-committers

From Heikki Linnakangas
Subject pgsql: Fix multixact backwards-compatibility with CHECKPOINT race condi
Date
Msg-id E1w4cd5-0014H5-1W@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix multixact backwards-compatibility with CHECKPOINT race condition

If a CHECKPOINT record with nextMulti N is written to the WAL before
the CREATE_ID record for N, and N happens to be the first multixid on
an offset page, the backwards compatibility logic to tolerate WAL
generated by older minor versions (before commit 789d65364c) failed to
compensate for the missing XLOG_MULTIXACT_ZERO_OFF_PAGE record. In
that case, the latest_page_number was initialized at the start of WAL
replay to the page for nextMulti from the CHECKPOINT record, even if
we had not seen the CREATE_ID record for that multixid yet, which
fooled the backwards compatibility logic to think that the page was
already initialized.

To fix, track the last XLOG_MULTIXACT_ZERO_OFF_PAGE that we've seen
separately from latest_page_number. If we haven't seen any
XLOG_MULTIXACT_ZERO_OFF_PAGE records yet, use
SimpleLruDoesPhysicalPageExist() to check if the page needs to be
initialized.

Reported-by: duankunren.dkr <duankunren.dkr@alibaba-inc.com>
Analyzed-by: duankunren.dkr <duankunren.dkr@alibaba-inc.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Discussion: https://www.postgresql.org/message-id/c4ef1737-8cba-458e-b6fd-4e2d6011e985.duankunren.dkr@alibaba-inc.com
Backpatch-through: 14-18

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1ca38503219abf6b291c47c7586a8a82f8014f8d

Modified Files
--------------
src/backend/access/transam/multixact.c | 87 +++++++++++++++++++++++++++-------
src/include/access/slru.h              |  4 +-
2 files changed, 70 insertions(+), 21 deletions(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Fix invalid value of pg_aios.pid, function pg_get_aios()
Next
From: Tom Lane
Date:
Subject: pgsql: Improve commentary about ChangeVarNodesWalkExpression().