From 8c122a1c98e6dffe60a288facf1605c1836f86c8 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Sun, 29 Jun 2025 17:38:37 +0300 Subject: [PATCH] Don't call into the old LFC when using the new communicator This fixes errors like `index "pg_class_relname_nsp_index" contains unexpected zero page at block 2` when running the python tests smgrzeroextend() still called into the old LFC's lfc_write() function, even when using the new communicator, which zeroed some arbitrary pages in the LFC file, overwriting pages managed by the new LFC implementation managed by `integrated_cache.rs` --- pgxn/neon/file_cache.c | 15 +++++++++++++++ pgxn/neon/pagestore_smgr.c | 11 +++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/pgxn/neon/file_cache.c b/pgxn/neon/file_cache.c index 2f9536ffd6..8b28d7f179 100644 --- a/pgxn/neon/file_cache.c +++ b/pgxn/neon/file_cache.c @@ -693,6 +693,7 @@ lfc_prewarm(FileCacheState* fcs, uint32 n_workers) dsm_segment *seg; BackgroundWorkerHandle* bgw_handle[MAX_PREWARM_WORKERS]; + Assert(!neon_enable_new_communicator); if (!lfc_ensure_opened()) return; @@ -847,6 +848,8 @@ lfc_prewarm_main(Datum main_arg) PrewarmWorkerState* ws; uint32 worker_id = DatumGetInt32(main_arg); + Assert(!neon_enable_new_communicator); + AmPrewarmWorker = true; pqsignal(SIGTERM, die); @@ -947,6 +950,8 @@ lfc_invalidate(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber nblocks) FileCacheEntry *entry; uint32 hash; + Assert(!neon_enable_new_communicator); + if (lfc_maybe_disabled()) /* fast exit if file cache is disabled */ return; @@ -992,6 +997,8 @@ lfc_cache_contains(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber blkno) bool found = false; uint32 hash; + Assert(!neon_enable_new_communicator); + if (lfc_maybe_disabled()) /* fast exit if file cache is disabled */ return false; @@ -1027,6 +1034,8 @@ lfc_cache_containsv(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber blkno, uint32 hash; int i = 0; + Assert(!neon_enable_new_communicator); + if (lfc_maybe_disabled()) /* fast exit if file cache is disabled */ return 0; @@ -1134,6 +1143,8 @@ lfc_readv_select(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber blkno, int blocks_read = 0; int buf_offset = 0; + Assert(!neon_enable_new_communicator); + if (lfc_maybe_disabled()) /* fast exit if file cache is disabled */ return -1; @@ -1500,6 +1511,8 @@ lfc_prefetch(NRelFileInfo rinfo, ForkNumber forknum, BlockNumber blkno, int chunk_offs = BLOCK_TO_CHUNK_OFF(blkno); + Assert(!neon_enable_new_communicator); + if (lfc_maybe_disabled()) /* fast exit if file cache is disabled */ return false; @@ -1645,6 +1658,8 @@ lfc_writev(NRelFileInfo rinfo, ForkNumber forkNum, BlockNumber blkno, uint32 entry_offset; int buf_offset = 0; + Assert(!neon_enable_new_communicator); + if (lfc_maybe_disabled()) /* fast exit if file cache is disabled */ return; diff --git a/pgxn/neon/pagestore_smgr.c b/pgxn/neon/pagestore_smgr.c index 445f1e9ac8..f52513e036 100644 --- a/pgxn/neon/pagestore_smgr.c +++ b/pgxn/neon/pagestore_smgr.c @@ -1104,11 +1104,14 @@ neon_zeroextend(SMgrRelation reln, ForkNumber forkNum, BlockNumber start_block, lsn = XLogInsert(RM_XLOG_ID, XLOG_FPI); - for (int i = 0; i < count; i++) + if (!neon_enable_new_communicator) { - lfc_write(InfoFromSMgrRel(reln), forkNum, blocknum + i, buffer.data); - neon_set_lwlsn_block(lsn, InfoFromSMgrRel(reln), forkNum, - blocknum + i); + for (int i = 0; i < count; i++) + { + lfc_write(InfoFromSMgrRel(reln), forkNum, blocknum + i, buffer.data); + neon_set_lwlsn_block(lsn, InfoFromSMgrRel(reln), forkNum, + blocknum + i); + } } blocknum += count;