Use ShareUpdateExclusiveLock instead ShareLock in VACUUM

Before this change, we used ShareLock to acquire lock on distributed tables while
running VACUUM. This makes VACUUM and INSERT block each other. With this change we
changed lock mode from ShareLock to ShareUpdateExclusiveLock, which does not conflict
with the locks INSERT acquire.
pull/1561/head
Burak Yucesoy 2017-07-10 13:55:34 +03:00 committed by Jason Petersen
parent e735655d82
commit ab509db0d8
1 changed files with 7 additions and 2 deletions

View File

@ -1248,8 +1248,13 @@ VacuumTaskList(Oid relationId, VacuumStmt *vacuumStmt)
char *schemaName = get_namespace_name(schemaId);
char *tableName = get_rel_name(relationId);
/* lock relation metadata before getting shard list */
LockRelationDistributionMetadata(relationId, ShareLock);
/*
* We obtain ShareUpdateExclusiveLock here to not conflict with INSERT's
* RowExclusiveLock. However if VACUUM FULL is used, we already obtain
* AccessExclusiveLock before reaching to that point and INSERT's will be
* blocked anyway. This is inline with PostgreSQL's own behaviour.
*/
LockRelationOid(relationId, ShareUpdateExclusiveLock);
shardIntervalList = LoadShardIntervalList(relationId);