pg_rewind: Fix thinko in parsing target WAL.
It's entirely possible to see WAL for a relation that doesn't exist in the target anymore. That happens when the relation was dropped later. The refactoring in commit eb00f1d4b broke that case, by sanity-checking the file type in the target before checking the flag forwhether it exists there at all. I noticed this during manual testing. Modify the 001_basic.pl test so that it covers this case.
This commit is contained in:
parent
3f16cb505d
commit
72d172743e
@ -324,17 +324,20 @@ process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode,
|
|||||||
{
|
{
|
||||||
Assert(entry->isrelfile);
|
Assert(entry->isrelfile);
|
||||||
|
|
||||||
if (entry->target_type != FILE_TYPE_REGULAR)
|
if (entry->target_exists)
|
||||||
pg_fatal("unexpected page modification for non-regular file \"%s\"",
|
|
||||||
entry->path);
|
|
||||||
|
|
||||||
if (entry->target_exists && entry->source_exists)
|
|
||||||
{
|
{
|
||||||
off_t end_offset;
|
if (entry->target_type != FILE_TYPE_REGULAR)
|
||||||
|
pg_fatal("unexpected page modification for non-regular file \"%s\"",
|
||||||
|
entry->path);
|
||||||
|
|
||||||
end_offset = (blkno_inseg + 1) * BLCKSZ;
|
if (entry->source_exists)
|
||||||
if (end_offset <= entry->source_size && end_offset <= entry->target_size)
|
{
|
||||||
datapagemap_add(&entry->target_pages_to_overwrite, blkno_inseg);
|
off_t end_offset;
|
||||||
|
|
||||||
|
end_offset = (blkno_inseg + 1) * BLCKSZ;
|
||||||
|
if (end_offset <= entry->source_size && end_offset <= entry->target_size)
|
||||||
|
datapagemap_add(&entry->target_pages_to_overwrite, blkno_inseg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ sub run_test
|
|||||||
primary_psql("VACUUM tail_tbl");
|
primary_psql("VACUUM tail_tbl");
|
||||||
|
|
||||||
# Drop drop_tbl. pg_rewind should copy it back.
|
# Drop drop_tbl. pg_rewind should copy it back.
|
||||||
|
primary_psql("insert into drop_tbl values ('in primary, after promotion')");
|
||||||
primary_psql("DROP TABLE drop_tbl");
|
primary_psql("DROP TABLE drop_tbl");
|
||||||
|
|
||||||
# Before running pg_rewind, do a couple of extra tests with several
|
# Before running pg_rewind, do a couple of extra tests with several
|
||||||
|
Loading…
x
Reference in New Issue
Block a user