postgresql/src/backend/postmaster
Robert Haas 53b327f83e Wait for WAL summarization to catch up before creating .partial file.
When a standby is promoted, CleanupAfterArchiveRecovery() may decide
to rename the final WAL file from the old timeline by adding ".partial"
to the name. If WAL summarization is enabled and this file is renamed
before its partial contents are summarized, WAL summarization breaks:
the summarizer gets stuck at that point in the WAL stream and just
errors out.

To fix that, first make the startup process wait for WAL summarization
to catch up before renaming the file. Generally, this should be quick,
and if it's not, the user can shut off summarize_wal and try again.
To make this fix work, also teach the WAL summarizer that after a
promotion has occurred, no more WAL can appear on the previous
timeline: previously, the WAL summarizer wouldn't switch to the new
timeline until we actually started writing WAL there, but that meant
that when the startup process was waiting for the WAL summarizer, it
was waiting for an action that the summarizer wasn't yet prepared to
take.

In the process of fixing these bugs, I realized that the logic to wait
for WAL summarization to catch up was spread out in a way that made
it difficult to reuse properly, so this code refactors things to make
it easier.

Finally, add a test case that would have caught this bug and the
previously-fixed bug that WAL summarization sometimes needs to back up
when the timeline changes.

Discussion: https://postgr.es/m/CA+TgmoZGEsZodXC4f=XZNkAeyuDmWTSkpkjCEOcF19Am0mt_OA@mail.gmail.com
2024-07-26 14:51:10 -04:00
..
autovacuum.c Avoid repeating loads of frozen ID values. 2024-04-29 10:25:33 -07:00
auxprocess.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00
bgworker.c Unify some error messages 2024-06-20 11:10:26 +02:00
bgwriter.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00
checkpointer.c Fix bugs in MultiXact truncation 2024-06-26 23:02:06 +03:00
fork_process.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
interrupt.c Centralize logic for restoring errno in signal handlers. 2024-02-14 16:34:18 -06:00
launch_backend.c Fix using injection points at backend startup in EXEC_BACKEND mode 2024-07-26 15:12:12 +03:00
Makefile Move some functions from postmaster.c to a new source file 2024-03-18 11:35:05 +02:00
meson.build Move some functions from postmaster.c to a new source file 2024-03-18 11:35:05 +02:00
pgarch.c A few follow-up fixes for GUC name quoting 2024-05-17 13:48:31 +02:00
postmaster.c Revise GUC names quoting in messages again 2024-05-17 11:44:26 +02:00
startup.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00
syslogger.c Avoid function call overhead of pg_popcount() in syslogger.c. 2024-04-02 10:32:49 -05:00
walsummarizer.c Wait for WAL summarization to catch up before creating .partial file. 2024-07-26 14:51:10 -04:00
walwriter.c Refactor postmaster child process launching 2024-03-18 11:35:30 +02:00