Commit 72d17274 authored by Heikki Linnakangas's avatar Heikki Linnakangas

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 eb00f1d4 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.
parent 3f16cb50
...@@ -324,11 +324,13 @@ process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode, ...@@ -324,11 +324,13 @@ process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode,
{ {
Assert(entry->isrelfile); Assert(entry->isrelfile);
if (entry->target_exists)
{
if (entry->target_type != FILE_TYPE_REGULAR) if (entry->target_type != FILE_TYPE_REGULAR)
pg_fatal("unexpected page modification for non-regular file \"%s\"", pg_fatal("unexpected page modification for non-regular file \"%s\"",
entry->path); entry->path);
if (entry->target_exists && entry->source_exists) if (entry->source_exists)
{ {
off_t end_offset; off_t end_offset;
...@@ -337,6 +339,7 @@ process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode, ...@@ -337,6 +339,7 @@ process_target_wal_block_change(ForkNumber forknum, RelFileNode rnode,
datapagemap_add(&entry->target_pages_to_overwrite, blkno_inseg); datapagemap_add(&entry->target_pages_to_overwrite, blkno_inseg);
} }
} }
}
} }
/* /*
......
...@@ -71,6 +71,7 @@ sub run_test ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment