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/1938/head
Jason Petersen 2016-02-16 11:20:18 -07:00
parent 3da8105af9
commit 130e65f5be
2 changed files with 5 additions and 2 deletions

View File

@ -153,7 +153,7 @@ CommutativityRuleToLockMode(CmdType commandType, bool upsertQuery)
static void
AcquireExecutorShardLock(Task *task, LOCKMODE lockMode)
{
int64 shardId = task->shardId;
int64 shardId = task->anchorShardId;
LockShardResource(shardId, lockMode);
}

View File

@ -14,9 +14,10 @@
*/
#include "postgres.h"
#include "c.h"
#include "miscadmin.h"
#include "distributed/relay_utility.h"
#include "distributed/resource_lock.h"
#include "storage/lmgr.h"
@ -68,6 +69,8 @@ LockShardResource(uint64 shardId, LOCKMODE lockmode)
const bool sessionLock = false;
const bool dontWait = false;
AssertArg(shardId != INVALID_SHARD_ID);
SET_LOCKTAG_SHARD_RESOURCE(tag, MyDatabaseId, shardId);
(void) LockAcquire(&tag, lockmode, sessionLock, dontWait);