mirror of https://github.com/citusdata/citus.git
Change the order in which the locks are acquired.
parent
aeded49fc8
commit
1b8ed32189
|
@ -707,13 +707,10 @@ SerializeNonCommutativeWrites(List *shardIntervalList, LOCKMODE lockMode)
|
|||
}
|
||||
|
||||
List *replicatedShardList = NIL;
|
||||
if (AnyTableReplicated(shardIntervalList, &replicatedShardList))
|
||||
{
|
||||
if (ClusterHasKnownMetadataWorkers() && !IsFirstWorkerNode())
|
||||
{
|
||||
LockShardListResourcesOnFirstWorker(lockMode, replicatedShardList);
|
||||
}
|
||||
bool anyTableReplicated = AnyTableReplicated(shardIntervalList, &replicatedShardList);
|
||||
|
||||
if (anyTableReplicated)
|
||||
{
|
||||
ShardInterval *firstShardInterval =
|
||||
(ShardInterval *) linitial(replicatedShardList);
|
||||
if (ReferenceTableShardId(firstShardInterval->shardId))
|
||||
|
@ -728,7 +725,10 @@ SerializeNonCommutativeWrites(List *shardIntervalList, LOCKMODE lockMode)
|
|||
LockReferencedReferenceShardResources(firstShardInterval->shardId, lockMode);
|
||||
}
|
||||
}
|
||||
|
||||
if (anyTableReplicated && ClusterHasKnownMetadataWorkers() && !IsFirstWorkerNode())
|
||||
{
|
||||
LockShardListResourcesOnFirstWorker(lockMode, replicatedShardList);
|
||||
}
|
||||
LockShardListResources(shardIntervalList, lockMode);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,16 +45,16 @@ SELECT * FROM master_run_on_worker(
|
|||
true);
|
||||
node_name | node_port | success | result
|
||||
---------------------------------------------------------------------
|
||||
localhost | 57638 | f | ERROR: deadlock detected
|
||||
localhost | 57638 | t | UPDATE 1
|
||||
localhost | 57637 | t | UPDATE 1
|
||||
localhost | 57637 | t | UPDATE 1
|
||||
localhost | 57638 | t | UPDATE 1
|
||||
localhost | 57637 | t | UPDATE 1
|
||||
localhost | 57638 | t | UPDATE 1
|
||||
localhost | 57637 | t | UPDATE 1
|
||||
localhost | 57638 | t | UPDATE 1
|
||||
localhost | 57638 | t | UPDATE 1
|
||||
localhost | 57637 | t | UPDATE 1
|
||||
localhost | 57637 | f | ERROR: deadlock detected
|
||||
localhost | 57638 | f | ERROR: deadlock detected
|
||||
localhost | 57637 | f | ERROR: canceling the transaction since it was involved in a distributed deadlock
|
||||
localhost | 57638 | f | ERROR: deadlock detected
|
||||
localhost | 57637 | f | ERROR: deadlock detected
|
||||
localhost | 57638 | f | ERROR: deadlock detected
|
||||
localhost | 57638 | f | ERROR: canceling the transaction since it was involved in a distributed deadlock
|
||||
localhost | 57637 | f | ERROR: deadlock detected
|
||||
(10 rows)
|
||||
|
||||
--- cleanup
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
--- Test for updating a table that has a foreign key reference to another reference table.
|
||||
--- Test for updating a table that has a foreign key reference to another reference table.
|
||||
--- Issue #7477: Distributed deadlock after issuing a simple UPDATE statement
|
||||
--- https://github.com/citusdata/citus/issues/7477
|
||||
|
||||
|
@ -15,7 +15,7 @@ CREATE TABLE table2 (
|
|||
SELECT create_reference_table('table2');
|
||||
INSERT INTO table2 VALUES (1, 'test');
|
||||
|
||||
--- Runs the update command in parallel on workers.
|
||||
--- Runs the update command in parallel on workers.
|
||||
--- Due to bug #7477, before the fix, the result is non-deterministic
|
||||
--- and have several rows of the form:
|
||||
--- localhost | 57638 | f | ERROR: deadlock detected
|
||||
|
@ -23,7 +23,7 @@ INSERT INTO table2 VALUES (1, 'test');
|
|||
--- localhost | 57637 | f | ERROR: canceling the transaction since it was involved in a distributed deadlock
|
||||
|
||||
SELECT * FROM master_run_on_worker(
|
||||
ARRAY['localhost', 'localhost','localhost', 'localhost','localhost',
|
||||
ARRAY['localhost', 'localhost','localhost', 'localhost','localhost',
|
||||
'localhost','localhost', 'localhost','localhost', 'localhost']::text[],
|
||||
ARRAY[57638, 57637, 57637, 57638, 57637, 57638, 57637, 57638, 57638, 57637]::int[],
|
||||
ARRAY['UPDATE table2 SET info = ''test_update'' WHERE id = 1',
|
||||
|
|
Loading…
Reference in New Issue