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

Commit 22cb257

Browse files
knizhnikkelvich
authored andcommitted
Add ATX fixes for multimaster
1 parent 93e5e41 commit 22cb257

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

multimaster.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ static void* MtmCreateSavepointContext(void);
167167
static void MtmRestoreSavepointContext(void* ctx);
168168
static void MtmReleaseSavepointContext(void* ctx);
169169
static void MtmSetRemoteFunction(char const* list, void* extra);
170+
static void* MtmSuspendTransaction(void);
171+
static void MtmResumeTransaction(void* ctx);
170172

171173
// static void MtmCheckClusterLock(void);
172174
static void MtmCheckSlots(void);
@@ -219,7 +221,9 @@ static TransactionManager MtmTM =
219221
MtmInitializeSequence,
220222
MtmCreateSavepointContext,
221223
MtmRestoreSavepointContext,
222-
MtmReleaseSavepointContext
224+
MtmReleaseSavepointContext,
225+
MtmSuspendTransaction,
226+
MtmResumeTransaction
223227
};
224228

225229
char const* const MtmNodeStatusMnem[] =
@@ -558,6 +562,22 @@ static void MtmReleaseSavepointContext(void* ctx)
558562
{
559563
}
560564

565+
static void* MtmSuspendTransaction(void)
566+
{
567+
MtmCurrentTrans* ctx = malloc(sizeof(MtmCurrentTrans));
568+
*ctx = MtmTx;
569+
MtmResetTransaction();
570+
MtmBeginTransaction(&MtmTx);
571+
return ctx;
572+
}
573+
574+
static void MtmResumeTransaction(void* ctx)
575+
{
576+
MtmTx = *(MtmCurrentTrans*)ctx;
577+
MtmInsideTransaction = true;
578+
free(ctx);
579+
}
580+
561581

562582
/*
563583
* -------------------------------------------
@@ -966,6 +986,7 @@ MtmBeginTransaction(MtmCurrentTrans* x)
966986
x->isSuspended = false;
967987
x->isTwoPhase = false;
968988
x->isTransactionBlock = IsTransactionBlock();
989+
969990
/* Application name can be changed using PGAPPNAME environment variable */
970991
if (x->isDistributed && Mtm->status != MTM_ONLINE && strcmp(application_name, MULTIMASTER_ADMIN) != 0
971992
&& strcmp(application_name, MULTIMASTER_BROADCAST_SERVICE) != 0
@@ -4717,6 +4738,7 @@ static bool MtmTwoPhaseCommit(MtmCurrentTrans* x)
47174738

47184739
if (!x->isReplicated && x->isDistributed && x->containsDML) {
47194740
MtmGenerateGid(x->gid);
4741+
47204742
if (!x->isTransactionBlock) {
47214743
BeginTransactionBlock(false);
47224744
x->isTransactionBlock = true;

0 commit comments

Comments
 (0)