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/1488/head
Burak Yucesoy 2017-07-10 13:55:34 +03:00
parent 2a4eada150
commit cb6070c720
1 changed files with 7 additions and 2 deletions

View File

@ -1331,8 +1331,13 @@ VacuumTaskList(Oid relationId, VacuumStmt *vacuumStmt)
char *schemaName = get_namespace_name(schemaId); char *schemaName = get_namespace_name(schemaId);
char *tableName = get_rel_name(relationId); 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); shardIntervalList = LoadShardIntervalList(relationId);