question about zeroes in the wal file names

From: Luca Ferrari <fluca1978(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: question about zeroes in the wal file names
Date: 2019-08-18 14:17:03
Message-ID: CAKoxK+67oS+PSygdmRHbn-GSjE_TY+t6Gzk6CRzcw-HVGswzOA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm just curious to better understand the naming convention behind wal
files, because I've seen on a system of mine that the wals created
were:

000000050000020E000000FF
000000050000020F00000000

while I was expecting 20E0x100. So I digged into the code and I've
seen, from the XLogFileName macro, that the last part is built as the
reminder of the number of segments per wal file:

#define XLogFileName(fname, tli, logSegNo, wal_segsz_bytes) \
snprintf(fname, MAXFNAMELEN, "%08X%08X%08X", tli, \
(uint32) ((logSegNo) / XLogSegmentsPerXLogId(wal_segsz_bytes)), \
(uint32) ((logSegNo) % XLogSegmentsPerXLogId(wal_segsz_bytes)))

and with the default wal size of 16 MB that gives a remainder of 256
(FF + 1). Assuming I haven't missed anything, this means that there
are 6 zeroes that will never change in the last 8 chars of the wal
filename. Is therefore this only done to handle PostgreSQL WAL sizes
of 4 GB each?

Thanks,
Luca

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2019-08-18 16:25:10 Re: Missing Trigger after pgdump install
Previous Message Melvin Davidson 2019-08-18 00:06:50 Re: How to determine what is preventing deleting a rule