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

Commit ab0399c

Browse files
knizhnikkelvich
authored andcommitted
Send seqno in hansshake response
1 parent e995f59 commit ab0399c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

arbiter.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ static int MtmConnectSocket(char const* host, int port, int timeout)
465465

466466
/* Some node considered that I am dead, so switch to recovery mode */
467467
MtmLock(LW_EXCLUSIVE);
468+
Mtm->nodes[resp.node-1].sendSeqNo = resp.seqno;
468469
if (BIT_CHECK(resp.disabledNodeMask, MtmNodeId-1)) {
469470
elog(WARNING, "Node %d thinks that I was dead", resp.node);
470471
BIT_SET(Mtm->disabledNodeMask, MtmNodeId-1);
@@ -576,6 +577,7 @@ static void MtmAcceptOneConnection()
576577
resp.sxid = ShmemVariableCache->nextXid;
577578
resp.csn = MtmGetCurrentTime();
578579
resp.node = MtmNodeId;
580+
resp.seqno = Mtm->nodes[req.hdr.node-1].recvSeqNo;
579581
MtmUpdateNodeConnectionInfo(&Mtm->nodes[req.hdr.node-1].con, req.connStr);
580582
if (!MtmWriteSocket(fd, &resp, sizeof resp)) {
581583
elog(WARNING, "Arbiter failed to write response for handshake message to node %d", resp.node);

multimaster.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,15 @@ MtmResetTransaction(MtmCurrentTrans* x)
663663
x->status = TRANSACTION_STATUS_UNKNOWN;
664664
}
665665

666+
667+
static const char* const isoLevelStr[] =
668+
{
669+
"read uncommitted",
670+
"read committed",
671+
"repeatable read",
672+
"serializable"
673+
};
674+
666675
static void
667676
MtmBeginTransaction(MtmCurrentTrans* x)
668677
{
@@ -679,13 +688,16 @@ MtmBeginTransaction(MtmCurrentTrans* x)
679688
x->isPrepared = false;
680689
x->isTransactionBlock = IsTransactionBlock();
681690
/* Application name can be changed usnig PGAPPNAME environment variable */
682-
if (!IsBackgroundWorker && x->isDistributed && Mtm->status != MTM_ONLINE && strcmp(application_name, MULTIMASTER_ADMIN) != 0) {
691+
if (x->isDistributed && Mtm->status != MTM_ONLINE && strcmp(application_name, MULTIMASTER_ADMIN) != 0) {
683692
/* Reject all user's transactions at offline cluster.
684693
* Allow execution of transaction by bg-workers to make it possible to perform recovery.
685694
*/
686695
MtmUnlock();
687696
elog(ERROR, "Multimaster node is not online: current status %s", MtmNodeStatusMnem[Mtm->status]);
688697
}
698+
if (x->isDistributed && XactIsoLevel != XACT_REPEATABLE_READ) {
699+
elog(LOG, "Isolation level %s is not supported by multimaster", isoLevelStr[XactIsoLevel]);
700+
}
689701
x->containsDML = false;
690702
x->snapshot = MtmAssignCSN();
691703
x->gtid.xid = InvalidTransactionId;
@@ -2163,6 +2175,13 @@ _PG_init(void)
21632175
NULL
21642176
);
21652177

2178+
if (DefaultXactIsoLevel != XACT_REPEATABLE_READ) {
2179+
elog(ERROR, "Multimaster requires repeatable read default isolation level");
2180+
}
2181+
if (synchronous_commit != SYNCHRONOUS_COMMIT_ON) {
2182+
elog(ERROR, "Multimaster requires synchronous commit on");
2183+
}
2184+
21662185
MtmSplitConnStrs();
21672186
MtmStartReceivers();
21682187

0 commit comments

Comments
 (0)