StartupXLOG: Don't repeatedly disable/enable local xlog insertion.
authorRobert Haas <rhaas@postgresql.org>
Mon, 25 Oct 2021 14:16:28 +0000 (10:16 -0400)
committerRobert Haas <rhaas@postgresql.org>
Mon, 25 Oct 2021 14:16:28 +0000 (10:16 -0400)
commit18e0913a420349d373cfd8e45b91b4777501fb74
tree176aad78da1b696606e635489dc3c4d87f0492d3
parenta75dbf7f9ee6ff0c0e2ab4b224b04fc50c4e6577
StartupXLOG: Don't repeatedly disable/enable local xlog insertion.

All the code that runs in the startup process to write WAL records
before that's allowed generally is now consecutive, so there's no
reason to shut the facility to write WAL locally off and then turn
it on again three times in a row.

Unfortunately, this requires a slight kludge in the checkpointer,
which needs to separately enable writing WAL in order to write the
checkpoint record. Because that code might run in the same process
as StartupXLOG() if we are in single-user mode, we must save/restore
the state of the LocalXLogInsertAllowed flag. Hopefully, we'll be
able to eliminate this wart in further refactoring, but it's
not too bad anyway.

Amul Sul, with modifications by me.

Discussion: http://postgr.es/m/CAAJ_b97fysj6sRSQEfOHj-y8Jfd5uPqOgO74qast89B4WfD+TA@mail.gmail.com
src/backend/access/transam/xlog.c