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;
|
List *replicatedShardList = NIL;
|
||||||
if (AnyTableReplicated(shardIntervalList, &replicatedShardList))
|
bool anyTableReplicated = AnyTableReplicated(shardIntervalList, &replicatedShardList);
|
||||||
{
|
|
||||||
if (ClusterHasKnownMetadataWorkers() && !IsFirstWorkerNode())
|
|
||||||
{
|
|
||||||
LockShardListResourcesOnFirstWorker(lockMode, replicatedShardList);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (anyTableReplicated)
|
||||||
|
{
|
||||||
ShardInterval *firstShardInterval =
|
ShardInterval *firstShardInterval =
|
||||||
(ShardInterval *) linitial(replicatedShardList);
|
(ShardInterval *) linitial(replicatedShardList);
|
||||||
if (ReferenceTableShardId(firstShardInterval->shardId))
|
if (ReferenceTableShardId(firstShardInterval->shardId))
|
||||||
|
@ -728,7 +725,10 @@ SerializeNonCommutativeWrites(List *shardIntervalList, LOCKMODE lockMode)
|
||||||
LockReferencedReferenceShardResources(firstShardInterval->shardId, lockMode);
|
LockReferencedReferenceShardResources(firstShardInterval->shardId, lockMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (anyTableReplicated && ClusterHasKnownMetadataWorkers() && !IsFirstWorkerNode())
|
||||||
|
{
|
||||||
|
LockShardListResourcesOnFirstWorker(lockMode, replicatedShardList);
|
||||||
|
}
|
||||||
LockShardListResources(shardIntervalList, lockMode);
|
LockShardListResources(shardIntervalList, lockMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,16 +45,16 @@ SELECT * FROM master_run_on_worker(
|
||||||
true);
|
true);
|
||||||
node_name | node_port | success | result
|
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 | 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)
|
(10 rows)
|
||||||
|
|
||||||
--- cleanup
|
--- 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
|
--- Issue #7477: Distributed deadlock after issuing a simple UPDATE statement
|
||||||
--- https://github.com/citusdata/citus/issues/7477
|
--- https://github.com/citusdata/citus/issues/7477
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ CREATE TABLE table2 (
|
||||||
SELECT create_reference_table('table2');
|
SELECT create_reference_table('table2');
|
||||||
INSERT INTO table2 VALUES (1, 'test');
|
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
|
--- Due to bug #7477, before the fix, the result is non-deterministic
|
||||||
--- and have several rows of the form:
|
--- and have several rows of the form:
|
||||||
--- localhost | 57638 | f | ERROR: deadlock detected
|
--- 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
|
--- localhost | 57637 | f | ERROR: canceling the transaction since it was involved in a distributed deadlock
|
||||||
|
|
||||||
SELECT * FROM master_run_on_worker(
|
SELECT * FROM master_run_on_worker(
|
||||||
ARRAY['localhost', 'localhost','localhost', 'localhost','localhost',
|
ARRAY['localhost', 'localhost','localhost', 'localhost','localhost',
|
||||||
'localhost','localhost', 'localhost','localhost', 'localhost']::text[],
|
'localhost','localhost', 'localhost','localhost', 'localhost']::text[],
|
||||||
ARRAY[57638, 57637, 57637, 57638, 57637, 57638, 57637, 57638, 57638, 57637]::int[],
|
ARRAY[57638, 57637, 57637, 57638, 57637, 57638, 57637, 57638, 57638, 57637]::int[],
|
||||||
ARRAY['UPDATE table2 SET info = ''test_update'' WHERE id = 1',
|
ARRAY['UPDATE table2 SET info = ''test_update'' WHERE id = 1',
|
||||||
|
|
Loading…
Reference in New Issue