elog(ERROR, "pg_class entry for relid %u vanished during vacuuming",
relid);
+ /* ensure no one else does this at the same time */
+ LockBuffer(buffer, BUFFER_LOCK_EXCLUSIVE);
+
/* overwrite the existing statistics in the tuple */
pgcform = (Form_pg_class) GETSTRUCT(&rtup);
pgcform->relpages = (int32) num_pages;
if (!hasindex)
pgcform->relhaspkey = false;
+ LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
+
/*
* Invalidate the tuple in the catcaches; this also arranges to flush
* the relation's relcache entry. (If we fail to commit for some
if (!HeapTupleIsValid(tuple))
elog(ERROR, "could not find tuple for database %u", dbid);
+ /* ensure no one else does this at the same time */
+ LockBuffer(scan->rs_cbuf, BUFFER_LOCK_EXCLUSIVE);
+
dbform = (Form_pg_database) GETSTRUCT(tuple);
/* overwrite the existing statistics in the tuple */
dbform->datvacuumxid = vacuumXID;
dbform->datfrozenxid = frozenXID;
+ LockBuffer(scan->rs_cbuf, BUFFER_LOCK_UNLOCK);
+
/* invalidate the tuple in the cache and write the buffer */
CacheInvalidateHeapTuple(relation, tuple);
WriteNoReleaseBuffer(scan->rs_cbuf);