On 10/11/2025 19:46, Heikki Linnakangas wrote:
Fixed. And I just noticed another thing I forgot: pg_resetwal and
pg_controldata.
Fixed that.
While testing, I noticed that pg_controldata doesn't check
PG_CONTROL_VERSION. If you add a field to ControlFileData that changes
the length, you'll get a warning that the CRC doesn't match:
pg_controldata: warning: calculated CRC checksum does not match value
stored in control file
pg_controldata: detail: Either the control file is corrupt, or it has
a different layout than this program is expecting. The results below
are untrustworthy.
but if you make any changes that *don't* change ControlFileData's size,
pg_controldata will merrily try to interpret the values with no warning.
Surely it should also check PG_CONTROL_VERSION?
Committed an additional version check to pg_controldata. It now gives a
a more explicit warning than just checksum failure if the version in the
control file doesn't match the PG_CONTROL_VERSION that the binary was
built with:
~/git-sandbox-pgsql/master$ ./src/bin/pg_controldata/pg_controldata -D
~/pgsql.18stable/data
pg_controldata: warning: control file version (1800) does not match the version
understood by this program (1900)
pg_controldata: detail: Either the control file has been created with a
different version of PostgreSQL, or it is corrupt. The results below are
untrustworthy.
pg_controldata: warning: invalid WAL segment size in control file (64 bytes)
pg_controldata: detail: The WAL segment size must be a power of two between 1
MB and 1 GB.
pg_controldata: detail: The file is corrupt and the results below are
untrustworthy.
pg_control version number: 1800
Catalog version number: 202506291
Database system identifier: 7571514922284774749
Database cluster state: shut down
pg_control last modified: Tue 11 Nov 2025 19:04:53 EET
...
- Heikki