diff --git a/src/backend/distributed/commands/create_distributed_table.c b/src/backend/distributed/commands/create_distributed_table.c index 0c37c9b9f..5c453770a 100644 --- a/src/backend/distributed/commands/create_distributed_table.c +++ b/src/backend/distributed/commands/create_distributed_table.c @@ -16,6 +16,7 @@ #include "access/htup.h" #include "access/htup_details.h" #include "access/nbtree.h" +#include "access/xact.h" #include "catalog/dependency.h" #include "catalog/index.h" #include "catalog/indexing.h" @@ -252,6 +253,8 @@ master_create_distributed_table(PG_FUNCTION_ARGS) RecordDistributedRelationDependencies(distributedRelationId, distributionKey); + CommandCounterIncrement(); + heap_close(pgDistPartition, NoLock); relation_close(distributedRelation, NoLock); diff --git a/src/backend/distributed/master/master_metadata_utility.c b/src/backend/distributed/master/master_metadata_utility.c index 97faa6518..533fa7e3e 100644 --- a/src/backend/distributed/master/master_metadata_utility.c +++ b/src/backend/distributed/master/master_metadata_utility.c @@ -424,11 +424,12 @@ InsertShardRow(Oid relationId, uint64 shardId, char storageType, simple_heap_insert(pgDistShard, heapTuple); CatalogUpdateIndexes(pgDistShard, heapTuple); - CommandCounterIncrement(); - /* close relation and invalidate previous cache entry */ - heap_close(pgDistShard, RowExclusiveLock); + /* invalidate previous cache entry and close relation */ CitusInvalidateRelcacheByRelid(relationId); + + CommandCounterIncrement(); + heap_close(pgDistShard, RowExclusiveLock); } @@ -464,9 +465,8 @@ InsertShardPlacementRow(uint64 shardId, char shardState, uint64 shardLength, simple_heap_insert(pgDistShardPlacement, heapTuple); CatalogUpdateIndexes(pgDistShardPlacement, heapTuple); - CommandCounterIncrement(); - /* close relation */ + CommandCounterIncrement(); heap_close(pgDistShardPlacement, RowExclusiveLock); } @@ -507,13 +507,14 @@ DeleteShardRow(uint64 shardId) distributedRelationId = pgDistShardForm->logicalrelid; simple_heap_delete(pgDistShard, &heapTuple->t_self); - CommandCounterIncrement(); systable_endscan(scanDescriptor); - heap_close(pgDistShard, RowExclusiveLock); /* invalidate previous cache entry */ CitusInvalidateRelcacheByRelid(distributedRelationId); + + CommandCounterIncrement(); + heap_close(pgDistShard, RowExclusiveLock); } @@ -567,9 +568,9 @@ DeleteShardPlacementRow(uint64 shardId, char *workerName, uint32 workerPort) } simple_heap_delete(pgDistShardPlacement, &heapTuple->t_self); - CommandCounterIncrement(); - systable_endscan(scanDescriptor); + + CommandCounterIncrement(); heap_close(pgDistShardPlacement, RowExclusiveLock); }