From 7f440847e0177840e64cdc6c72d9feef57ca9445 Mon Sep 17 00:00:00 2001 From: reshke Date: Tue, 25 Aug 2026 05:20:11 +0000 Subject: [PATCH 1/2] Fix extnesible SMGR API violation in ao_truncate replay --- src/backend/cdb/cdbappendonlyxlog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/cdb/cdbappendonlyxlog.c b/src/backend/cdb/cdbappendonlyxlog.c index 6b717978b31..8f2aaa89c0f 100644 --- a/src/backend/cdb/cdbappendonlyxlog.c +++ b/src/backend/cdb/cdbappendonlyxlog.c @@ -177,7 +177,7 @@ ao_truncate_replay(XLogReaderState *record) return; } - if (FileTruncate(file, xlrec->target.offset, WAIT_EVENT_DATA_FILE_TRUNCATE) != 0) + if (smgr->smgr_ao->smgr_FileTruncate(file, xlrec->target.offset, WAIT_EVENT_DATA_FILE_TRUNCATE) != 0) { ereport(WARNING, (errcode_for_file_access(), @@ -185,7 +185,7 @@ ao_truncate_replay(XLogReaderState *record) path, xlrec->target.offset))); } - FileClose(file); + smgr->smgr_ao->smgr_FileClose(file); } void From 53d8302ff66f217f77883f509000a610ea65809e Mon Sep 17 00:00:00 2001 From: reshke Date: Tue, 25 Aug 2026 10:45:46 +0000 Subject: [PATCH 2/2] Fix same issue with vacuum progress reporting; also close fd after use --- src/backend/access/appendonly/aomd.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/access/appendonly/aomd.c b/src/backend/access/appendonly/aomd.c index 342e7771b7b..df07769f033 100644 --- a/src/backend/access/appendonly/aomd.c +++ b/src/backend/access/appendonly/aomd.c @@ -714,9 +714,12 @@ ao_segfile_get_physical_size(Relation aorel, int segno, FileNumber filenum) filenum, segno, fileSegNo); - fd = PathNameOpenFile(filenamepath, O_RDONLY | PG_BINARY); + fd = aorel->rd_smgr->smgr_ao->smgr_AORelOpenSegFile(RelationGetRelid(aorel), filenamepath, O_RDONLY | PG_BINARY); if (fd >= 0) - physical_size = FileDiskSize(fd); + { + physical_size = aorel->rd_smgr->smgr_ao->smgr_FileDiskSize(fd); + aorel->rd_smgr->smgr_ao->smgr_FileClose(fd); + } else elogif(Debug_appendonly_print_compaction, LOG, "No gp_relation_node entry for append-optimized relation \"%s\", relation id %u, relfilenode %u filenum #%d, logical segment #%d (physical segment file #%d)", @@ -726,5 +729,6 @@ ao_segfile_get_physical_size(Relation aorel, int segno, FileNumber filenum) filenum, segno, fileSegNo); + return physical_size; }