END_CRIT_SECTION();
+ /*
+ * Since it could contend with concurrent cleanup process we cleanup
+ * pending list not forcibly.
+ */
if (needCleanup)
- ginInsertCleanup(ginstate, false, true, NULL);
+ ginInsertCleanup(ginstate, false, true, false, NULL);
}
/*
*/
void
ginInsertCleanup(GinState *ginstate, bool full_clean,
- bool fill_fsm, IndexBulkDeleteResult *stats)
+ bool fill_fsm, bool forceCleanup,
+ IndexBulkDeleteResult *stats)
{
Relation index = ginstate->index;
Buffer metabuffer,
bool cleanupFinish = false;
bool fsm_vac = false;
Size workMemory;
- bool inVacuum = (stats == NULL);
/*
* We would like to prevent concurrent cleanup process. For that we will
* insertion into pending list
*/
- if (inVacuum)
+ if (forceCleanup)
{
/*
* We are called from [auto]vacuum/analyze or gin_clean_pending_list()
memset(&stats, 0, sizeof(stats));
initGinState(&ginstate, indexRel);
- ginInsertCleanup(&ginstate, true, true, &stats);
+ ginInsertCleanup(&ginstate, true, true, true, &stats);
index_close(indexRel, AccessShareLock);
* and cleanup any pending inserts
*/
ginInsertCleanup(&gvs.ginstate, !IsAutoVacuumWorkerProcess(),
- false, stats);
+ false, true, stats);
}
/* we'll re-count the tuples each time */
if (IsAutoVacuumWorkerProcess())
{
initGinState(&ginstate, index);
- ginInsertCleanup(&ginstate, false, true, stats);
+ ginInsertCleanup(&ginstate, false, true, true, stats);
}
return stats;
}
stats = (IndexBulkDeleteResult *) palloc0(sizeof(IndexBulkDeleteResult));
initGinState(&ginstate, index);
ginInsertCleanup(&ginstate, !IsAutoVacuumWorkerProcess(),
- false, stats);
+ false, true, stats);
}
memset(&idxStat, 0, sizeof(idxStat));
OffsetNumber attnum, Datum value, bool isNull,
ItemPointer ht_ctid);
extern void ginInsertCleanup(GinState *ginstate, bool full_clean,
- bool fill_fsm, IndexBulkDeleteResult *stats);
+ bool fill_fsm, bool forceCleanup, IndexBulkDeleteResult *stats);
/* ginpostinglist.c */