From 32ef4590250eb8f1d9173d2ef6370d496fa540ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= Date: Wed, 28 Aug 2019 19:08:04 +0000 Subject: [PATCH] backend_data.c: include max_wal_senders in calculating maxBackend, matches changes in pg12's InitializeMaxBackends --- .../distributed/transaction/backend_data.c | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/backend/distributed/transaction/backend_data.c b/src/backend/distributed/transaction/backend_data.c index 43ddd877c..3114347e3 100644 --- a/src/backend/distributed/transaction/backend_data.c +++ b/src/backend/distributed/transaction/backend_data.c @@ -28,6 +28,9 @@ #include "distributed/tuplestore.h" #include "nodes/execnodes.h" #include "postmaster/autovacuum.h" /* to access autovacuum_max_workers */ +#if PG_VERSION_NUM >= 120000 +#include "replication/walsender.h" +#endif #include "storage/ipc.h" #include "storage/lmgr.h" #include "storage/lwlock.h" @@ -518,9 +521,10 @@ BackendManagementShmemInit(void) totalProcs = TotalProcCount(); for (backendIndex = 0; backendIndex < totalProcs; ++backendIndex) { - backendManagementShmemData->backends[backendIndex].citusBackend. - initiatorNodeIdentifier = -1; - SpinLockInit(&backendManagementShmemData->backends[backendIndex].mutex); + BackendData *backendData = + &backendManagementShmemData->backends[backendIndex]; + backendData->citusBackend.initiatorNodeIdentifier = -1; + SpinLockInit(&backendData->mutex); } } @@ -587,12 +591,16 @@ TotalProcCount(void) * We prefer to maintain space for auxiliary procs or preperad transactions in * the backend space because they could be blocking processes and our current * implementation of distributed deadlock detection could process them - * as a regular backend. In the future, we could consider chaning deadlock - * detection algorithm to ignore auxiliary procs or preperad transactions and - * save same space. + * as a regular backend. In the future, we could consider changing deadlock + * detection algorithm to ignore auxiliary procs or prepared transactions and + * save some space. */ totalProcs = maxBackends + NUM_AUXILIARY_PROCS + max_prepared_xacts; +#if PG_VERSION_NUM >= 120000 + totalProcs += max_wal_senders; +#endif + return totalProcs; }