Don't open a WAL segment for writing at end of recovery.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 7 Jan 2015 14:11:33 +0000 (16:11 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 7 Jan 2015 14:20:20 +0000 (16:20 +0200)
commit1e78d81e883d7987de8da559d985958335820cc8
treeaed83bd57d63e3d5579988f2ff66ac723ee82a01
parent79af9a1d2668c9edc8171f03c39e7fed571eeb98
Don't open a WAL segment for writing at end of recovery.

Since commit ba94518a, we used XLogFileOpen to open the next segment for
writing, but if the end-of-recovery happens exactly at a segment boundary,
the new segment might not exist yet. (Before ba94518a, XLogFileOpen was
correct, because we would open the previous segment if the switch happened
at the boundary.)

Instead of trying to create it if necessary, it's simpler to not bother
opening the segment at all. XLogWrite() will open or create it soon anyway,
after writing the checkpoint or end-of-recovery record.

Reported by Andres Freund.
src/backend/access/transam/xlog.c