Skip to content

Commit 72d1727

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 in the target anymore. That happens when the relation was dropped later. The refactoring in commit eb00f1d 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.
1 parent 3f16cb5 commit 72d1727

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_t end_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_t end_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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy