*/
RelationTruncate(onerel, new_rel_pages);
- /* Now we're OK to release the lock. */
- UnlockRelation(onerel, AccessExclusiveLock);
+ /*
+ * Note: once we have truncated, we *must* keep the exclusive lock
+ * until commit. The sinval message that will be sent at commit
+ * (as a result of vac_update_relstats()) must be received by other
+ * backends, to cause them to reset their rd_targblock values, before
+ * they can safely access the table again.
+ */
/*
* Drop free-space info for removed blocks; these must not get entered