Move neon_pgstat_file_size_limit to the extension (#10959)

## Problem

PG14 uses separate backend for stats collector having no access to
shaerd memory.
As far as AUX mechanism requires access to shared memory, persisting
pgstat.stat file
is not supported at pg14. And so there is no definition of
`neon_pgstat_file_size_limit`
variable. It makes it impossible to provide same config for all Postgres
version.

## Summary of changes

Move neon_pgstat_file_size_limit to Neon extension.

Postgres submodules PR:
https://github.com/neondatabase/postgres/pull/587
https://github.com/neondatabase/postgres/pull/588
https://github.com/neondatabase/postgres/pull/589

---------

Co-authored-by: Konstantin Knizhnik <knizhnik@neon.tech>
Co-authored-by: Tristan Partin <tristan@neon.tech>
This commit is contained in:
Konstantin Knizhnik
2025-02-25 14:23:04 +02:00
committed by GitHub
parent 758f597280
commit 8f82c661d4
6 changed files with 27 additions and 7 deletions

View File

@@ -12,6 +12,7 @@
#include "fmgr.h" #include "fmgr.h"
#include "miscadmin.h" #include "miscadmin.h"
#include "pgstat.h"
#include "access/subtrans.h" #include "access/subtrans.h"
#include "access/twophase.h" #include "access/twophase.h"
#include "access/xlog.h" #include "access/xlog.h"
@@ -410,6 +411,16 @@ ReportSearchPath(void)
} }
} }
#if PG_VERSION_NUM < 150000
/*
* PG14 uses separate backend for stats collector having no access to shared memory.
* As far as AUX mechanism requires access to shared memory, persisting pgstat.stat file
* is not supported in PG14. And so there is no definition of neon_pgstat_file_size_limit
* variable, so we have to declare it here.
*/
static int neon_pgstat_file_size_limit;
#endif
void void
_PG_init(void) _PG_init(void)
{ {
@@ -467,6 +478,15 @@ _PG_init(void)
0, 0,
NULL, NULL, NULL); NULL, NULL, NULL);
DefineCustomIntVariable("neon.pgstat_file_size_limit",
"Maximal size of pgstat.stat file saved in Neon storage",
"Zero value disables persisting pgstat.stat file",
&neon_pgstat_file_size_limit,
0, 0, 1000000, /* disabled by default */
PGC_SIGHUP,
GUC_UNIT_KB,
NULL, NULL, NULL);
/* /*
* Important: This must happen after other parts of the extension are * Important: This must happen after other parts of the extension are
* loaded, otherwise any settings to GUCs that were set before the * loaded, otherwise any settings to GUCs that were set before the

View File

@@ -13,7 +13,7 @@ def test_pgstat(neon_simple_env: NeonEnv):
n = 10000 n = 10000
endpoint = env.endpoints.create_start( endpoint = env.endpoints.create_start(
"main", config_lines=["neon_pgstat_file_size_limit=100kB", "autovacuum=off"] "main", config_lines=["neon.pgstat_file_size_limit=100kB", "autovacuum=off"]
) )
con = endpoint.connect() con = endpoint.connect()

View File

@@ -1,15 +1,15 @@
{ {
"v17": [ "v17": [
"17.4", "17.4",
"59b2fe851f8e0595f6c830b90ee766f4f1c17a0f" "517b8dc244abf3e56f0089849e464af76f70b94e"
], ],
"v16": [ "v16": [
"16.8", "16.8",
"261ed10e9b8c8dda01ad7aefb18e944e30aa161d" "799e7a08dd171aa06a7395dd326f4243aaeb9f93"
], ],
"v15": [ "v15": [
"15.12", "15.12",
"6ff50443773b69749e16da6db9d4f4b19064b4b7" "9b118b1cffa6e4ca0d63389b57b54d11e207e9a8"
], ],
"v14": [ "v14": [
"14.17", "14.17",