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

Commit a1ea5f5

Browse files
committed
Preserve commit order
1 parent c42c8d6 commit a1ea5f5

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

contrib/mmts/multimaster.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ int MtmHeartbeatSendTimeout;
208208
int MtmHeartbeatRecvTimeout;
209209
bool MtmUseRaftable;
210210
bool MtmUseDtm;
211+
bool MtmPreserveCommitOrder;
211212
bool MtmVolksWagenMode;
212213

213214
TransactionId MtmUtilityProcessedInXid;
@@ -2342,6 +2343,19 @@ _PG_init(void)
23422343
NULL
23432344
);
23442345

2346+
DefineCustomBoolVariable(
2347+
"multimaster.preserve_commit_order",
2348+
"Transactions from one node will be committed in same order al all nodes",
2349+
NULL,
2350+
&MtmPreserveCommitOrder,
2351+
true,
2352+
PGC_BACKEND,
2353+
0,
2354+
NULL,
2355+
NULL,
2356+
NULL
2357+
);
2358+
23452359
DefineCustomBoolVariable(
23462360
"multimaster.volkswagen_mode",
23472361
"Pretend to be normal postgres. This means skip some NOTICE's and use local sequences. Default false.",

contrib/mmts/multimaster.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#define MB (1024*1024L)
5959

6060
#define USEC_TO_MSEC(t) ((t)/1000)
61-
#define MSEC_TO_USEC(t) ((t)*1000)
61+
#define MSEC_TO_USEC(t) ((timestamp_t)(t)*1000)
6262

6363
#define Natts_mtm_ddl_log 2
6464
#define Anum_mtm_ddl_log_issued 1
@@ -287,6 +287,7 @@ extern int MtmTransSpillThreshold;
287287
extern int MtmHeartbeatSendTimeout;
288288
extern int MtmHeartbeatRecvTimeout;
289289
extern bool MtmUseDtm;
290+
extern bool MtmPreserveCommitOrder;
290291
extern HTAB* MtmXid2State;
291292
extern HTAB* MtmGid2State;
292293

contrib/mmts/pglogical_receiver.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,12 @@ pglogical_receiver_main(Datum main_arg)
527527
spill_file = -1;
528528
resetStringInfo(&spill_info);
529529
} else {
530-
MtmExecute(buf.data, buf.used);
530+
if (MtmPreserveCommitOrder && buf.used == rc - hdr_len) {
531+
/* Perform commit-prepared and rollback-prepared requested directly in receiver */
532+
MtmExecutor(nodeId, buf.data, buf.used);
533+
} else {
534+
MtmExecute(buf.data, buf.used);
535+
}
531536
}
532537
ByteBufferReset(&buf);
533538
}

0 commit comments

Comments
 (0)