Make object locking explicit while adding dependencies

pull/5480/head
Burak Velioglu 2021-11-18 19:33:56 +03:00
parent 77d948a595
commit b484d9b234
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
1 changed files with 11 additions and 0 deletions

View File

@ -88,6 +88,17 @@ EnsureDependenciesExistOnAllNodes(const ObjectAddress *target)
*/
List *workerNodeList = ActivePrimaryNonCoordinatorNodeList(RowShareLock);
/*
* Lock dependent objects explicitly to make sure same DDL command won't be sent
* multiple times from parallel sessions. Having IF EXISTS may not handle locking
* issues if sent from parallel sessions.
*/
foreach_ptr(dependency, dependenciesWithCommands)
{
LockDatabaseObject(dependency->classId, dependency->objectId,
dependency->objectSubId, RowExclusiveLock);
}
/*
* right after we acquired the lock we mark our objects as distributed, these changes
* will not become visible before we have successfully created all the objects on our