diff --git a/src/backend/access/gin/ginfast.c b/src/backend/access/gin/ginfast.c index 0034889..5fbd3ec 100644 --- a/src/backend/access/gin/ginfast.c +++ b/src/backend/access/gin/ginfast.c @@ -765,7 +765,7 @@ ginInsertCleanup(GinState *ginstate, bool full_clean, bool cleanupFinish = false; bool fsm_vac = false; Size workMemory; - bool inVacuum = (stats == NULL); + bool inVacuum = (stats != NULL); /* * We would like to prevent concurrent cleanup process. For that we will diff --git a/src/backend/access/gin/ginvacuum.c b/src/backend/access/gin/ginvacuum.c index a20a99c..82e9077 100644 --- a/src/backend/access/gin/ginvacuum.c +++ b/src/backend/access/gin/ginvacuum.c @@ -683,6 +683,10 @@ ginvacuumcleanup(IndexVacuumInfo *info, IndexBulkDeleteResult *stats) if (IsAutoVacuumWorkerProcess()) { initGinState(&ginstate, index); + + /* Make stats non-NULL to ensure cleaning up pending inserts */ + if (stats == NULL) + stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult)); ginInsertCleanup(&ginstate, false, true, stats); } return stats;