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

Commit72d1727

Browse files
committed
pg_rewind: Fix thinko in parsing target WAL.
It's entirely possible to see WAL for a relation that doesn't exist inthe target anymore. That happens when the relation was dropped later.The refactoring in commiteb00f1d broke that case, by sanity-checkingthe file type in the target before checking the flag forwhether itexists there at all.I noticed this during manual testing. Modify the 001_basic.pl test sothat it covers this case.
1 parent3f16cb5 commit72d1727

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

‎src/bin/pg_rewind/filemap.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,20 @@ process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode,
324324
{
325325
Assert(entry->isrelfile);
326326

327-
if (entry->target_type!=FILE_TYPE_REGULAR)
328-
pg_fatal("unexpected page modification for non-regular file \"%s\"",
329-
entry->path);
330-
331-
if (entry->target_exists&&entry->source_exists)
327+
if (entry->target_exists)
332328
{
333-
off_tend_offset;
329+
if (entry->target_type!=FILE_TYPE_REGULAR)
330+
pg_fatal("unexpected page modification for non-regular file \"%s\"",
331+
entry->path);
334332

335-
end_offset= (blkno_inseg+1)*BLCKSZ;
336-
if (end_offset <=entry->source_size&&end_offset <=entry->target_size)
337-
datapagemap_add(&entry->target_pages_to_overwrite,blkno_inseg);
333+
if (entry->source_exists)
334+
{
335+
off_tend_offset;
336+
337+
end_offset= (blkno_inseg+1)*BLCKSZ;
338+
if (end_offset <=entry->source_size&&end_offset <=entry->target_size)
339+
datapagemap_add(&entry->target_pages_to_overwrite,blkno_inseg);
340+
}
338341
}
339342
}
340343
}

‎src/bin/pg_rewind/t/001_basic.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ sub run_test
7171
primary_psql("VACUUM tail_tbl");
7272

7373
# Drop drop_tbl. pg_rewind should copy it back.
74+
primary_psql("insert into drop_tbl values ('in primary, after promotion')");
7475
primary_psql("DROP TABLE drop_tbl");
7576

7677
# Before running pg_rewind, do a couple of extra tests with several

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp