diff --git a/pgxn/neon/communicator.c b/pgxn/neon/communicator.c index da2f0643d1..ddbdaa1c97 100644 --- a/pgxn/neon/communicator.c +++ b/pgxn/neon/communicator.c @@ -65,6 +65,7 @@ #include "miscadmin.h" #include "port/pg_iovec.h" #include "postmaster/interrupt.h" +#include "postmaster/postmaster.h" #include "replication/walsender.h" #include "storage/ipc.h" #include "utils/timeout.h" @@ -328,7 +329,7 @@ pg_init_communicator(void) static Size CommunicatorShmemSize(void) { - return (MaxBackends + NUM_AUXILIARY_PROCS + max_prepared_xacts) * sizeof(XLogRecPtr); + return (MAX_BACKENDS + NUM_AUXILIARY_PROCS + max_prepared_xacts) * sizeof(XLogRecPtr); } void @@ -2686,7 +2687,7 @@ communicator_processinterrupts(void) XLogRecPtr communicator_get_min_prefetch_lsn(void) { - XLogRecPtr min_lsn = InvalidXLogRecPtr; + XLogRecPtr min_lsn = GetXLogReplayRecPtr(NULL); size_t n_procs = ProcGlobal->allProcCount; for (size_t i = 0; i < n_procs; i++) { diff --git a/pgxn/neon/file_cache.c b/pgxn/neon/file_cache.c index 0886f21584..54c941ce7a 100644 --- a/pgxn/neon/file_cache.c +++ b/pgxn/neon/file_cache.c @@ -625,9 +625,6 @@ lfc_init(void) NULL, NULL, NULL); - - if (lfc_max_size == 0) - return; } FileCacheState* diff --git a/pgxn/neon/neon.c b/pgxn/neon/neon.c index 8347ec63a0..806111e693 100644 --- a/pgxn/neon/neon.c +++ b/pgxn/neon/neon.c @@ -457,15 +457,6 @@ _PG_init(void) load_file("$libdir/neon_rmgr", false); #endif -#if PG_VERSION_NUM >= 150000 - prev_shmem_request_hook = shmem_request_hook; - shmem_request_hook = neon_shmem_request_hook; -#else - neon_shmem_request_hook(); -#endif - prev_shmem_startup_hook = shmem_startup_hook; - shmem_startup_hook = neon_shmem_startup_hook; - /* dummy call to a Rust function in the communicator library, to check that it works */ (void) communicator_dummy(123); @@ -564,6 +555,16 @@ _PG_init(void) ReportSearchPath(); +#if PG_VERSION_NUM >= 150000 + prev_shmem_request_hook = shmem_request_hook; + shmem_request_hook = neon_shmem_request_hook; +#else + neon_shmem_request_hook(); +#endif + prev_shmem_startup_hook = shmem_startup_hook; + shmem_startup_hook = neon_shmem_startup_hook; + + prev_ExecutorStart = ExecutorStart_hook; ExecutorStart_hook = neon_ExecutorStart; prev_ExecutorEnd = ExecutorEnd_hook; @@ -656,6 +657,7 @@ neon_shmem_request_hook(void) if (prev_shmem_request_hook) prev_shmem_request_hook(); #endif + LfcShmemRequest(); NeonPerfCountersShmemRequest(); PagestoreShmemRequest(); diff --git a/pgxn/neon/relsize_cache.c b/pgxn/neon/relsize_cache.c index cf8d1bd841..bf7961574a 100644 --- a/pgxn/neon/relsize_cache.c +++ b/pgxn/neon/relsize_cache.c @@ -50,17 +50,17 @@ typedef struct * algorithm */ } RelSizeHashControl; -static HTAB *relsize_hash; -static LWLockId relsize_lock; -static int relsize_hash_size; -static RelSizeHashControl* relsize_ctl; - /* * Size of a cache entry is 36 bytes. So this default will take about 2.3 MB, * which seems reasonable. */ #define DEFAULT_RELSIZE_HASH_SIZE (64 * 1024) +static HTAB *relsize_hash; +static LWLockId relsize_lock; +static int relsize_hash_size = DEFAULT_RELSIZE_HASH_SIZE; +static RelSizeHashControl* relsize_ctl; + void RelsizeCacheShmemInit(void) {