mirror of
https://github.com/postgres/postgres.git
synced 2025-11-13 16:22:44 +03:00
Move SLRU_PAGES_PER_SEGMENT to pg_config_manual.h
It seems plausible that someone might want to experiment with different values. The pressing reason though is that I'm reviewing a patch that requires pg_upgrade to manipulate SLRU files. That patch needs to access SLRU_PAGES_PER_SEGMENT from pg_upgrade code, and slru.h, where SLRU_PAGES_PER_SEGMENT is currently defined, cannot be included from frontend code. Moving it to pg_config_manual.h makes it accessible. Now that it's a little more likely that someone might change SLRU_PAGES_PER_SEGMENT, add a cluster compatibility check for it. Bump catalog version because of the new field in the control file. Reviewed-by: Daniel Gustafsson <daniel@yesql.se> Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de> Discussion: https://www.postgresql.org/message-id/c7a4ea90-9f7b-4953-81be-b3fcb47db057@iki.fi
This commit is contained in:
@@ -4271,6 +4271,7 @@ WriteControlFile(void)
|
||||
|
||||
ControlFile->blcksz = BLCKSZ;
|
||||
ControlFile->relseg_size = RELSEG_SIZE;
|
||||
ControlFile->slru_pages_per_segment = SLRU_PAGES_PER_SEGMENT;
|
||||
ControlFile->xlog_blcksz = XLOG_BLCKSZ;
|
||||
ControlFile->xlog_seg_size = wal_segment_size;
|
||||
|
||||
@@ -4490,6 +4491,16 @@ ReadControlFile(void)
|
||||
"RELSEG_SIZE", ControlFile->relseg_size,
|
||||
"RELSEG_SIZE", RELSEG_SIZE),
|
||||
errhint("It looks like you need to recompile or initdb.")));
|
||||
if (ControlFile->slru_pages_per_segment != SLRU_PAGES_PER_SEGMENT)
|
||||
ereport(FATAL,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("database files are incompatible with server"),
|
||||
/* translator: %s is a variable name and %d is its value */
|
||||
errdetail("The database cluster was initialized with %s %d,"
|
||||
" but the server was compiled with %s %d.",
|
||||
"SLRU_PAGES_PER_SEGMENT", ControlFile->slru_pages_per_segment,
|
||||
"SLRU_PAGES_PER_SEGMENT", SLRU_PAGES_PER_SEGMENT),
|
||||
errhint("It looks like you need to recompile or initdb.")));
|
||||
if (ControlFile->xlog_blcksz != XLOG_BLCKSZ)
|
||||
ereport(FATAL,
|
||||
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
|
||||
@@ -23,21 +23,6 @@
|
||||
*/
|
||||
#define SLRU_MAX_ALLOWED_BUFFERS ((1024 * 1024 * 1024) / BLCKSZ)
|
||||
|
||||
/*
|
||||
* Define SLRU segment size. A page is the same BLCKSZ as is used everywhere
|
||||
* else in Postgres. The segment size can be chosen somewhat arbitrarily;
|
||||
* we make it 32 pages by default, or 256Kb, i.e. 1M transactions for CLOG
|
||||
* or 64K transactions for SUBTRANS.
|
||||
*
|
||||
* 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()).
|
||||
*/
|
||||
#define SLRU_PAGES_PER_SEGMENT 32
|
||||
|
||||
/*
|
||||
* Page status codes. Note that these do not include the "dirty" bit.
|
||||
* page_dirty can be true only in the VALID or WRITE_IN_PROGRESS states;
|
||||
|
||||
@@ -57,6 +57,6 @@
|
||||
*/
|
||||
|
||||
/* yyyymmddN */
|
||||
#define CATALOG_VERSION_NO 202511071
|
||||
#define CATALOG_VERSION_NO 202511101
|
||||
|
||||
#endif
|
||||
|
||||
@@ -207,6 +207,8 @@ typedef struct ControlFileData
|
||||
uint32 blcksz; /* data block size for this DB */
|
||||
uint32 relseg_size; /* blocks per segment of large relation */
|
||||
|
||||
uint32 slru_pages_per_segment; /* size of each SLRU segment */
|
||||
|
||||
uint32 xlog_blcksz; /* block size within WAL files */
|
||||
uint32 xlog_seg_size; /* size of each WAL segment */
|
||||
|
||||
|
||||
@@ -19,6 +19,16 @@
|
||||
*/
|
||||
#define DEFAULT_XLOG_SEG_SIZE (16*1024*1024)
|
||||
|
||||
/*
|
||||
* SLRU segment size. A page is the same BLCKSZ as is used everywhere else in
|
||||
* Postgres. The segment size can be chosen somewhat arbitrarily; we make it
|
||||
* 32 pages by default, or 256Kb, i.e. 1M transactions for CLOG or 64K
|
||||
* transactions for SUBTRANS.
|
||||
*
|
||||
* Changing this requires an initdb.
|
||||
*/
|
||||
#define SLRU_PAGES_PER_SEGMENT 32
|
||||
|
||||
/*
|
||||
* Maximum length for identifiers (e.g. table names, column names,
|
||||
* function names). Names actually are limited to one fewer byte than this,
|
||||
|
||||
Reference in New Issue
Block a user