Directly register multi-shard callbacks in PG_init

I had changed these callbacks to use the same method I chose for the
router executor (for consistency), but as that method is flawed, we now
want to ensure we directly register them from PG_init as well.
pull/818/head
Jason Petersen 2016-09-28 10:49:28 -06:00
parent 5f6264105d
commit 5b80d4e8dd
No known key found for this signature in database
GPG Key ID: 9F1D3510D110ABA9
3 changed files with 4 additions and 24 deletions

View File

@ -155,7 +155,7 @@ _PG_init(void)
/* initialize transaction callbacks */ /* initialize transaction callbacks */
RegisterRouterExecutorXactCallbacks(); RegisterRouterExecutorXactCallbacks();
InstallMultiShardXactShmemHook(); RegisterShardPlacementXactCallbacks();
} }

View File

@ -27,11 +27,9 @@
/* Global variables used in commit handler */ /* Global variables used in commit handler */
static HTAB *shardConnectionHash = NULL; static HTAB *shardConnectionHash = NULL;
static shmem_startup_hook_type prev_shmem_startup_hook = NULL;
static bool subXactAbortAttempted = false; static bool subXactAbortAttempted = false;
/* functions needed by callbacks and hooks */ /* functions needed by callbacks and hooks */
static void RegisterShardPlacementXactCallbacks(void);
static void CompleteShardPlacementTransactions(XactEvent event, void *arg); static void CompleteShardPlacementTransactions(XactEvent event, void *arg);
static void MultiShardSubXactCallback(SubXactEvent event, SubTransactionId subId, static void MultiShardSubXactCallback(SubXactEvent event, SubTransactionId subId,
SubTransactionId parentSubid, void *arg); SubTransactionId parentSubid, void *arg);
@ -229,32 +227,14 @@ ConnectionList(HTAB *connectionHash)
/* /*
* InstallMultiShardXactShmemHook simply installs a hook (intended to be called * RegisterShardPlacementXactCallbacks registers transaction callbacks needed
* once during backend startup), which will itself register all the transaction * for multi-shard transactions.
* callbacks needed by multi-shard transaction logic.
*/ */
void void
InstallMultiShardXactShmemHook(void)
{
prev_shmem_startup_hook = shmem_startup_hook;
shmem_startup_hook = RegisterShardPlacementXactCallbacks;
}
/*
* RegisterShardPlacementXactCallbacks registers transaction callbacks needed
* for multi-shard transactions before calling previous shmem startup hooks.
*/
static void
RegisterShardPlacementXactCallbacks(void) RegisterShardPlacementXactCallbacks(void)
{ {
RegisterXactCallback(CompleteShardPlacementTransactions, NULL); RegisterXactCallback(CompleteShardPlacementTransactions, NULL);
RegisterSubXactCallback(MultiShardSubXactCallback, NULL); RegisterSubXactCallback(MultiShardSubXactCallback, NULL);
if (prev_shmem_startup_hook != NULL)
{
prev_shmem_startup_hook();
}
} }

View File

@ -33,7 +33,7 @@ extern ShardConnections * GetShardHashConnections(HTAB *connectionHash, int64 sh
bool *connectionsFound); bool *connectionsFound);
extern List * ConnectionList(HTAB *connectionHash); extern List * ConnectionList(HTAB *connectionHash);
extern void CloseConnections(List *connectionList); extern void CloseConnections(List *connectionList);
extern void InstallMultiShardXactShmemHook(void); extern void RegisterShardPlacementXactCallbacks(void);
#endif /* MULTI_SHARD_TRANSACTION_H */ #endif /* MULTI_SHARD_TRANSACTION_H */