mirror of https://github.com/citusdata/citus.git
wip
parent
d3faf974ad
commit
11d5301d35
|
@ -1560,20 +1560,6 @@ LockPartitionsForDistributedPlan(DistributedPlan *distributedPlan)
|
||||||
Oid targetRelationId = distributedPlan->targetRelationId;
|
Oid targetRelationId = distributedPlan->targetRelationId;
|
||||||
|
|
||||||
LockPartitionsInRelationList(list_make1_oid(targetRelationId), RowExclusiveLock);
|
LockPartitionsInRelationList(list_make1_oid(targetRelationId), RowExclusiveLock);
|
||||||
|
|
||||||
if (PartitionTable(targetRelationId))
|
|
||||||
{
|
|
||||||
Oid parentRelationId = PartitionParentOid(targetRelationId);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Postgres only takes the lock on parent when the session accesses the
|
|
||||||
* partition for the first time. So it should be okay to get this lock from
|
|
||||||
* PG perspective. Even though we diverge from PG behavior for concurrent
|
|
||||||
* modifications on partitions vs CREATE/DROP partitions, we consider this as
|
|
||||||
* a reasonable trade-off to avoid distributed deadlocks.
|
|
||||||
*/
|
|
||||||
LockRelationOid(parentRelationId, AccessShareLock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1663,12 +1649,7 @@ LockParentShardResouceIfPartitionTaskList(List *taskList)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShardInterval *shardInterval = LoadShardInterval(shardId);
|
LockParentShardResourceIfPartition(shardId, AccessExclusiveLock);
|
||||||
Oid relationId = shardInterval->relationId;
|
|
||||||
if (PartitionTable(relationId))
|
|
||||||
{
|
|
||||||
LockParentShardResourceIfPartition(shardId, AccessExclusiveLock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@
|
||||||
#include "distributed/placement_connection.h"
|
#include "distributed/placement_connection.h"
|
||||||
#include "distributed/relay_utility.h"
|
#include "distributed/relay_utility.h"
|
||||||
#include "distributed/remote_commands.h"
|
#include "distributed/remote_commands.h"
|
||||||
|
#include "distributed/resource_lock.h"
|
||||||
#include "distributed/worker_protocol.h"
|
#include "distributed/worker_protocol.h"
|
||||||
#include "distributed/worker_transaction.h"
|
#include "distributed/worker_transaction.h"
|
||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
|
@ -332,11 +333,14 @@ DropShards(Oid relationId, char *schemaName, char *relationName,
|
||||||
deletableShardIntervalList);
|
deletableShardIntervalList);
|
||||||
bool shouldExecuteTasksLocally = ShouldExecuteTasksLocally(dropTaskList);
|
bool shouldExecuteTasksLocally = ShouldExecuteTasksLocally(dropTaskList);
|
||||||
|
|
||||||
|
|
||||||
Task *task = NULL;
|
Task *task = NULL;
|
||||||
foreach_ptr(task, dropTaskList)
|
foreach_ptr(task, dropTaskList)
|
||||||
{
|
{
|
||||||
uint64 shardId = task->anchorShardId;
|
uint64 shardId = task->anchorShardId;
|
||||||
|
|
||||||
|
LockParentShardResourceIfPartition(shardId, AccessExclusiveLock);
|
||||||
|
|
||||||
ShardPlacement *shardPlacement = NULL;
|
ShardPlacement *shardPlacement = NULL;
|
||||||
foreach_ptr(shardPlacement, task->taskPlacementList)
|
foreach_ptr(shardPlacement, task->taskPlacementList)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue