Skip to content

Commit 5ddf997

Browse files
committed
Temporary patch to help debug pg_walsummary test failures.
The tests in 002_blocks.pl are failing in the buildfarm from time to time, but we don't know how to reproduce the failure elsewhere. The most obvious explanation seems to be the unexpected disappearance of a WAL summary file, so bump up the logging level in RemoveWalSummaryIfOlderThan to try to help us spot such problems, and print the cutoff time in addition to the removed filename. Also adjust 002_blocks.pl to dump out a directory listing of the relevant directory at various points. This patch should be reverted once we sort out what's happening here. Patch by me, reviewed by Nathan Bossart, who also reported the issue. Discussion: http://postgr.es/m/20240124170846.GA2643050@nathanxps13
1 parent 5eafacd commit 5ddf997

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/backend/backup/walsummary.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,15 @@ RemoveWalSummaryIfOlderThan(WalSummaryFile *ws, time_t cutoff_time)
251251
ereport(ERROR,
252252
(errcode_for_file_access(),
253253
errmsg("could not stat file \"%s\": %m", path)));
254+
/* XXX temporarily changed to debug buildfarm failures */
255+
#if 0
254256
ereport(DEBUG2,
255257
(errmsg_internal("removing file \"%s\"", path)));
258+
#else
259+
ereport(LOG,
260+
(errmsg_internal("removing file \"%s\" cutoff_time=%llu", path,
261+
(unsigned long long) cutoff_time)));
262+
#endif
256263
}
257264

258265
/*

src/bin/pg_walsummary/t/002_blocks.pl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
EOM
4949
($summarized_tli, $summarized_lsn) = split(/\|/, $progress);
5050
note("after insert, summarized TLI $summarized_tli through $summarized_lsn");
51+
note_wal_summary_dir("after insert", $node1);
5152

5253
# Update a row in the first block of the table and trigger a checkpoint.
5354
$node1->safe_psql('postgres', <<EOM);
@@ -70,19 +71,32 @@
7071
EOM
7172
my ($tli, $start_lsn, $end_lsn) = split(/\|/, $details);
7273
note("examining summary for TLI $tli from $start_lsn to $end_lsn");
74+
note_wal_summary_dir("after new summary", $node1);
7375

7476
# Reconstruct the full pathname for the WAL summary file.
7577
my $filename = sprintf "%s/pg_wal/summaries/%08s%08s%08s%08s%08s.summary",
7678
$node1->data_dir, $tli,
7779
split(m@/@, $start_lsn),
7880
split(m@/@, $end_lsn);
7981
ok(-f $filename, "WAL summary file exists");
82+
note_wal_summary_dir("after existence check", $node1);
8083

8184
# Run pg_walsummary on it. We expect block 0 to be modified, but depending
8285
# on where the new tuple ends up, block 1 might also be modified, so we
8386
# pass -i to pg_walsummary to make sure we don't end up with a 0..1 range.
8487
my ($stdout, $stderr) = run_command([ 'pg_walsummary', '-i', $filename ]);
8588
like($stdout, qr/FORK main: block 0$/m, "stdout shows block 0 modified");
8689
is($stderr, '', 'stderr is empty');
90+
note_wal_summary_dir("after pg_walsummary run", $node1);
8791

8892
done_testing();
93+
94+
# XXX. Temporary debugging code.
95+
sub note_wal_summary_dir
96+
{
97+
my ($flair, $node) = @_;
98+
99+
my $wsdir = sprintf "%s/pg_wal/summaries", $node->data_dir;
100+
my @wsfiles = grep { $_ ne '.' && $_ ne '..' } slurp_dir($wsdir);
101+
note("$flair pg_wal/summaries has: @wsfiles");
102+
}

0 commit comments

Comments
 (0)