Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b381d96

Browse files
committed
Add timeline ID to file names generated with pg_waldump --save-fullpage
Not including the timeline IDs to the file names generated by pg_waldump for the individual blocks saved could cause some of these files to be overwritten when scanning segments across multiple timelines. Having this information is also as much useful as the LSNs, to be able to know from exactly which WAL segment a block is comes from. While on it, this fixes a few comments in the tests, where the format of the file was not described as matching with the reality. Reported-by: Fujii Masao Reviewed-by: Kyotaro Horiguchi, David Christensen Discussion: https://postgr.es/m/ZJp921+nITFnvBVS@paquier.xyz
1 parent fc55c7f commit b381d96

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

doc/src/sgml/ref/pg_waldump.sgml

+8-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ PostgreSQL documentation
283283
</para>
284284
<para>
285285
The full page images are saved with the following file name format:
286-
<literal><replaceable>LSN</replaceable>.<replaceable>RELTABLESPACE</replaceable>.<replaceable>DATOID</replaceable>.<replaceable>RELNODE</replaceable>.<replaceable>BLKNO</replaceable><replaceable>FORK</replaceable></literal>
286+
<literal><replaceable>TIMELINE</replaceable>-<replaceable>LSN</replaceable>.<replaceable>RELTABLESPACE</replaceable>.<replaceable>DATOID</replaceable>.<replaceable>RELNODE</replaceable>.<replaceable>BLKNO</replaceable><replaceable>FORK</replaceable></literal>
287287

288288
The file names are composed of the following parts:
289289
<informaltable>
@@ -296,6 +296,13 @@ PostgreSQL documentation
296296
</thead>
297297

298298
<tbody>
299+
<row>
300+
<entry>TIMELINE</entry>
301+
<entry>The timeline of the WAL segment file where the record
302+
is located formatted as one 8-character hexadecimal number
303+
<literal>%08X</literal></entry>
304+
</row>
305+
299306
<row>
300307
<entry>LSN</entry>
301308
<entry>The <acronym>LSN</acronym> of the record with this image,

src/bin/pg_waldump/pg_waldump.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ XLogRecordSaveFPWs(XLogReaderState *record, const char *savepath)
518518
else
519519
pg_fatal("invalid fork number: %u", fork);
520520

521-
snprintf(filename, MAXPGPATH, "%s/%08X-%08X.%u.%u.%u.%u%s", savepath,
521+
snprintf(filename, MAXPGPATH, "%s/%08X-%08X-%08X.%u.%u.%u.%u%s", savepath,
522+
record->seg.ws_tli,
522523
LSN_FORMAT_ARGS(record->ReadRecPtr),
523524
rnode.spcOid, rnode.dbOid, rnode.relNumber, blk, forkname);
524525

src/bin/pg_waldump/t/002_save_fullpage.pl

+5-4
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,16 @@ sub get_block_lsn
7979
'pg_waldump with --save-fullpage runs');
8080

8181
# This regexp will match filenames formatted as:
82-
# XXXXXXXX-XXXXXXXX.DBOID.TLOID.NODEOID.dd_fork with the components being:
83-
# - WAL LSN in hex format,
84-
# - Tablespace OID (0 for global)
82+
# TLI-LSNh-LSNl.TBLSPCOID.DBOID.NODEOID.dd_fork with the components being:
83+
# - Timeline ID in hex format.
84+
# - WAL LSN in hex format, as two 8-character numbers.
85+
# - Tablespace OID (0 for global).
8586
# - Database OID.
8687
# - Relfilenode.
8788
# - Block number.
8889
# - Fork this block came from (vm, init, fsm, or main).
8990
my $file_re =
90-
qr/^([0-9A-F]{8})-([0-9A-F]{8})[.][0-9]+[.][0-9]+[.][0-9]+[.][0-9]+(?:_vm|_init|_fsm|_main)?$/;
91+
qr/^[0-9A-F]{8}-([0-9A-F]{8})-([0-9A-F]{8})[.][0-9]+[.][0-9]+[.][0-9]+[.][0-9]+(?:_vm|_init|_fsm|_main)?$/;
9192

9293
my $file_count = 0;
9394

0 commit comments

Comments
 (0)