8000 Send seqno in hansshake response · m99coder/postgres_cluster@aebd817 · GitHub
[go: up one dir, main page]

Skip to content

Commit aebd817

Browse files
committed
Send seqno in hansshake response
1 parent 95ea058 commit aebd817

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

contrib/mmts/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);

contrib/mmts/multimaster.c

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

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

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

0 commit comments

Comments
 (0)
0