Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit303e46e

Browse files
committed
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 offailing.
1 parent09c6ac9 commit303e46e

File tree

1 file changed

+11
-2
lines changed
  • src/backend/storage/smgr

1 file changed

+11
-2
lines changed

‎src/backend/storage/smgr/md.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.111 2004/08/3002:54:39 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.112 2004/08/3003:52:43 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -937,10 +937,19 @@ _mdfd_getseg(SMgrRelation reln, BlockNumber blkno, bool allowNotFound)
937937
* "target" block.We should never need to create more than
938938
* one new segment per call, so this restriction seems
939939
* reasonable.
940+
*
941+
* BUT: when doing WAL recovery, disable this logic and create
942+
* segments unconditionally. In this case it seems better
943+
* to assume the given blkno is good (it presumably came from
944+
* a CRC-checked WAL record); furthermore this lets us cope
945+
* in the case where we are replaying WAL data that has a write
946+
* into a high-numbered segment of a relation that was later
947+
* deleted. We want to go ahead and create the segments so
948+
* we can finish out the replay.
940949
*/
941950
v->mdfd_chain=_mdfd_openseg(reln,
942951
nextsegno,
943-
(segstogo==1) ?O_CREAT :0);
952+
(segstogo==1||InRecovery) ?O_CREAT :0);
944953
if (v->mdfd_chain==NULL)
945954
{
946955
if (allowNotFound&&errno==ENOENT)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp