mirror of https://github.com/citusdata/citus.git
Ensure router executor acquires proper shard lock
Though Citus' Task struct has a shardId field, it doesn't have the same semantics as the one previously used in pg_shard code. The analogous field in the Citus Task is anchorShardId. I've also added an argument check to the relevant locking function to catch future locking attempts which pass an invalid argument.pull/344/head
parent
334f800016
commit
0d196d1bf4
|
@ -153,7 +153,7 @@ CommutativityRuleToLockMode(CmdType commandType, bool upsertQuery)
|
||||||
static void
|
static void
|
||||||
AcquireExecutorShardLock(Task *task, LOCKMODE lockMode)
|
AcquireExecutorShardLock(Task *task, LOCKMODE lockMode)
|
||||||
{
|
{
|
||||||
int64 shardId = task->shardId;
|
int64 shardId = task->anchorShardId;
|
||||||
|
|
||||||
LockShardResource(shardId, lockMode);
|
LockShardResource(shardId, lockMode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
#include "c.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
|
|
||||||
|
#include "distributed/relay_utility.h"
|
||||||
#include "distributed/resource_lock.h"
|
#include "distributed/resource_lock.h"
|
||||||
#include "storage/lmgr.h"
|
#include "storage/lmgr.h"
|
||||||
|
|
||||||
|
@ -68,6 +69,8 @@ LockShardResource(uint64 shardId, LOCKMODE lockmode)
|
||||||
const bool sessionLock = false;
|
const bool sessionLock = false;
|
||||||
const bool dontWait = false;
|
const bool dontWait = false;
|
||||||
|
|
||||||
|
AssertArg(shardId != INVALID_SHARD_ID);
|
||||||
|
|
||||||
SET_LOCKTAG_SHARD_RESOURCE(tag, MyDatabaseId, shardId);
|
SET_LOCKTAG_SHARD_RESOURCE(tag, MyDatabaseId, shardId);
|
||||||
|
|
||||||
(void) LockAcquire(&tag, lockmode, sessionLock, dontWait);
|
(void) LockAcquire(&tag, lockmode, sessionLock, dontWait);
|
||||||
|
|
Loading…
Reference in New Issue