mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-10-02 20:56:54 +02:00
Tweak md.c logic to cope with the situation where WAL replay tries to
write into a high-numbered segment of a relation that was later deleted. We need to temporarily recreate missing segment files, instead of failing.
This commit is contained in:
parent
09c6ac9513
commit
303e46ea93
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.111 2004/08/30 02:54:39 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.112 2004/08/30 03:52:43 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -937,10 +937,19 @@ _mdfd_getseg(SMgrRelation reln, BlockNumber blkno, bool allowNotFound)
|
|||||||
* "target" block. We should never need to create more than
|
* "target" block. We should never need to create more than
|
||||||
* one new segment per call, so this restriction seems
|
* one new segment per call, so this restriction seems
|
||||||
* reasonable.
|
* reasonable.
|
||||||
|
*
|
||||||
|
* BUT: when doing WAL recovery, disable this logic and create
|
||||||
|
* segments unconditionally. In this case it seems better
|
||||||
|
* to assume the given blkno is good (it presumably came from
|
||||||
|
* a CRC-checked WAL record); furthermore this lets us cope
|
||||||
|
* in the case where we are replaying WAL data that has a write
|
||||||
|
* into a high-numbered segment of a relation that was later
|
||||||
|
* deleted. We want to go ahead and create the segments so
|
||||||
|
* we can finish out the replay.
|
||||||
*/
|
*/
|
||||||
v->mdfd_chain = _mdfd_openseg(reln,
|
v->mdfd_chain = _mdfd_openseg(reln,
|
||||||
nextsegno,
|
nextsegno,
|
||||||
(segstogo == 1) ? O_CREAT : 0);
|
(segstogo == 1 || InRecovery) ? O_CREAT : 0);
|
||||||
if (v->mdfd_chain == NULL)
|
if (v->mdfd_chain == NULL)
|
||||||
{
|
{
|
||||||
if (allowNotFound && errno == ENOENT)
|
if (allowNotFound && errno == ENOENT)
|
||||||
|
Loading…
Reference in New Issue
Block a user