Move SLRU_PAGES_PER_SEGMENT to pg_config_manual.h

Heikki Linnakangas <hlinnaka@iki.fi>

From: Heikki Linnakangas <hlinnaka@iki.fi>
To: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Cc: Maxim Orlov <orlovmg@gmail.com>, Daniil Davydov <3danissimo@gmail.com>, Daniel Gustafsson <daniel@yesql.se>
Date: 2025-11-10T11:29:08Z
Lists: pgsql-hackers

Attachments

At the "make mxidoff 64 bits" thread [1], we're discussing moving 
SLRU_PAGES_PER_SEGMENT to pg_config_manual.h, to make it accessible from 
pg_upgrade code. It's currently defined in slru.h, which cannot be 
included in frontend code. There are many ways we could fix that, but 
moving SLRU_PAGES_PER_SEGMENT to pg_config_manual.h seems best to me. 
Patch attached.

There was a suggestion earlier to make SLRU_PAGES_PER_SEGMENT a 
configure option [2]. I don't want to go that far; pg_config_manual.h 
seems like the right level of configurability to me.

I'm raising this in a new thread for visibility, in case someone who 
hasn't been following the other threads have objections or better 
suggestions.

The patch does not move over this comment from slru.h:

> - * Note: because TransactionIds are 32 bits and wrap around at 0xFFFFFFFF,
> - * page numbering also wraps around at 0xFFFFFFFF/xxxx_XACTS_PER_PAGE (where
> - * xxxx is CLOG or SUBTRANS, respectively), and segment numbering at
> - * 0xFFFFFFFF/xxxx_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT.  We need
> - * take no explicit notice of that fact in slru.c, except when comparing
> - * segment and page numbers in SimpleLruTruncate (see PagePrecedes()).

I left it out because there's already a copy of the same comment next to 
CLOG_XACTS_PER_PAGE and SUBTRANS_XACTS_PER_PAGE. That seems enough.

[1] 
https://www.postgresql.org/message-id/CACG%3DezbZo_3_fnx%3DS5BfepwRftzrpJ%2B7WET4EkTU6wnjDTsnjg%40mail.gmail.com

[2] 
https://www.postgresql.org/message-id/CAJDiXgiSVjsMj7pCKrXjwoVb2UCo28Fifd2VndNgybfbAhjbpg%40mail.gmail.com

- Heikki

Commits

  1. Add warning to pg_controldata on PG_CONTROL_VERSION mismatch

  2. Add pg_resetwal and pg_controldata support for new control file field

  3. Bump PG_CONTROL_VERSION for commit 3e0ae46d90

  4. Move SLRU_PAGES_PER_SEGMENT to pg_config_manual.h