Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0ee9dba

Browse files
knizhnikkelvich
authored andcommitted
Change cluster configuration only if some node was enabled or disabled
1 parent 77fdb2c commit 0ee9dba

File tree

2 files changed

+25
-19
lines changed

2 files changed

+25
-19
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ USER postgres
3131
ENV CFLAGS -O0
3232
WORKDIR /pg
3333

34-
ENV REBUILD false
34+
ENV REBUILD 1
3535

3636
RUN cd /pg && \
3737
git clone https://github.com/postgrespro/postgres_cluster.git --depth 1 && \

multimaster.c

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ MtmBuildConnectivityMatrix(nodemask_t* matrix, bool nowait)
13501350
*/
13511351
bool MtmRefreshClusterStatus(bool nowait)
13521352
{
1353-
nodemask_t mask, clique, disabled;
1353+
nodemask_t mask, clique, disabled, enabled;
13541354
nodemask_t matrix[MAX_NODES];
13551355
MtmTransState *ts;
13561356
int clique_size;
@@ -1384,29 +1384,34 @@ bool MtmRefreshClusterStatus(bool nowait)
13841384
MtmDisableNode(i+1);
13851385
}
13861386
}
1387-
mask = clique & Mtm->disabledNodeMask; /* new enabled nodes mask */
1387+
1388+
enabled = clique & Mtm->disabledNodeMask; /* new enabled nodes mask */
1389+
1390+
mask = enabled;
13881391
for (i = 0; mask != 0; i++, mask >>= 1) {
13891392
if (mask & 1) {
13901393
MtmEnableNode(i+1);
13911394
}
13921395
}
1393-
MtmCheckQuorum();
1394-
/* Interrupt voting for active transaction and abort them */
1395-
for (ts = Mtm->transListHead; ts != NULL; ts = ts->next) {
1396-
MTM_LOG3("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d",
1397-
ts->gid, ts->gtid.node, ts->xid, ts->status, ts->gtid.xid);
1398-
if (MtmIsCoordinator(ts)) {
1399-
if (!ts->votingCompleted && ts->status != TRANSACTION_STATUS_ABORTED) {
1400-
MtmAbortTransaction(ts);
1401-
MtmWakeUpBackend(ts);
1402-
}
1403-
} else if (TransactionIdIsValid(ts->gtid.xid) && BIT_CHECK(disabled, ts->gtid.node-1)) { // coordinator of transaction is on disabled node
1404-
if (ts->gid[0]) {
1405-
if (ts->status == TRANSACTION_STATUS_UNKNOWN || ts->status == TRANSACTION_STATUS_IN_PROGRESS) {
1406-
MTM_LOG1("%d: Abort trasaction %s because its coordinator is at disabled node %d", MyProcPid, ts->gid, ts->gtid.node);
1396+
if (disabled|enabled) {
1397+
MtmCheckQuorum();
1398+
/* Interrupt voting for active transaction and abort them */
1399+
for (ts = Mtm->transListHead; ts != NULL; ts = ts->next) {
1400+
MTM_LOG3("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d",
1401+
ts->gid, ts->gtid.node, ts->xid, ts->status, ts->gtid.xid);
1402+
if (MtmIsCoordinator(ts)) {
1403+
if (!ts->votingCompleted && ts->status != TRANSACTION_STATUS_ABORTED) {
14071404
MtmAbortTransaction(ts);
1408-
MtmTx.status = TRANSACTION_STATUS_ABORTED; /* prevent recursive invocation of MtmAbortPreparedTransaction */
1409-
FinishPreparedTransaction(ts->gid, false);
1405+
MtmWakeUpBackend(ts);
1406+
}
1407+
} else if (TransactionIdIsValid(ts->gtid.xid) && BIT_CHECK(disabled, ts->gtid.node-1)) { // coordinator of transaction is on disabled node
1408+
if (ts->gid[0]) {
1409+
if (ts->status == TRANSACTION_STATUS_UNKNOWN || ts->status == TRANSACTION_STATUS_IN_PROGRESS) {
1410+
MTM_LOG1("%d: Abort trasaction %s because its coordinator is at disabled node %d", MyProcPid, ts->gid, ts->gtid.node);
1411+
MtmAbortTransaction(ts);
1412+
MtmTx.status = TRANSACTION_STATUS_ABORTED; /* prevent recursive invocation of MtmAbortPreparedTransaction */
1413+
FinishPreparedTransaction(ts->gid, false);
1414+
}
14101415
}
14111416
}
14121417
}
@@ -3285,6 +3290,7 @@ MtmDetectGlobalDeadLock(PGPROC* proc)
32853290
ByteBuffer buf;
32863291
PGXACT* pgxact = &ProcGlobal->allPgXact[proc->pgprocno];
32873292
bool hasDeadlock = false;
3293+
32883294
if (TransactionIdIsValid(pgxact->xid)) {
32893295
MtmGraph graph;
32903296
GlobalTransactionId gtid;

0 commit comments

Comments
 (0)