From 3c507e7399c54453d52fb3d00463df3c8ca84d59 Mon Sep 17 00:00:00 2001 From: Jason Petersen Date: Wed, 19 Apr 2017 20:29:05 -0600 Subject: [PATCH] Handle LWLockRegisterTranche changes The initialization of a custom lock tranche is somewhat simplified in PostgreSQL 10: now a name and identifier are sufficient. --- src/backend/distributed/worker/task_tracker.c | 9 +++++++++ src/include/distributed/task_tracker.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/backend/distributed/worker/task_tracker.c b/src/backend/distributed/worker/task_tracker.c index 1afabb371..3b94dfe0f 100644 --- a/src/backend/distributed/worker/task_tracker.c +++ b/src/backend/distributed/worker/task_tracker.c @@ -578,6 +578,13 @@ TaskTrackerShmemInit(void) if (!alreadyInitialized) { +#if (PG_VERSION_NUM >= 100000) + WorkerTasksSharedState->taskHashTrancheId = LWLockNewTrancheId(); + WorkerTasksSharedState->taskHashTrancheName = "Worker Task Hash Tranche"; + LWLockRegisterTranche(WorkerTasksSharedState->taskHashTrancheId, + WorkerTasksSharedState->taskHashTrancheName); +#else + /* initialize lwlock protecting the task tracker hash table */ LWLockTranche *tranche = &WorkerTasksSharedState->taskHashLockTranche; @@ -586,6 +593,8 @@ TaskTrackerShmemInit(void) tranche->array_stride = sizeof(LWLock); tranche->name = "Worker Task Hash Tranche"; LWLockRegisterTranche(WorkerTasksSharedState->taskHashTrancheId, tranche); +#endif + LWLockInitialize(&WorkerTasksSharedState->taskHashLock, WorkerTasksSharedState->taskHashTrancheId); } diff --git a/src/include/distributed/task_tracker.h b/src/include/distributed/task_tracker.h index 1b76d9547..20aa0a9cf 100644 --- a/src/include/distributed/task_tracker.h +++ b/src/include/distributed/task_tracker.h @@ -99,7 +99,11 @@ typedef struct WorkerTasksSharedStateData /* Lock protecting workerNodesHash */ int taskHashTrancheId; +#if (PG_VERSION_NUM >= 100000) + char *taskHashTrancheName; +#else LWLockTranche taskHashLockTranche; +#endif LWLock taskHashLock; } WorkerTasksSharedStateData;