Skip to content

Commit 9a51193

Browse files
committed
Update multimaster
1 parent 6810e26 commit 9a51193

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

contrib/multimaster/multimaster.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "storage/pmsignal.h"
4444
#include "storage/proc.h"
4545
#include "utils/syscache.h"
46+
#include "replication/walsender.h"
4647
#include "port/atomics.h"
4748

4849
#include "sockhub/sockhub.h"
@@ -757,7 +758,7 @@ DtmXactCallback(XactEvent event, void *arg)
757758
case XACT_EVENT_START:
758759
//XTM_INFO("%d: normal=%d, initialized=%d, replication=%d, bgw=%d, vacuum=%d\n",
759760
// getpid(), IsNormalProcessingMode(), dtm->initialized, MMDoReplication, IsBackgroundWorker, IsAutoVacuumWorkerProcess());
760-
if (IsNormalProcessingMode() && dtm->initialized && MMDoReplication && !IsBackgroundWorker && !IsAutoVacuumWorkerProcess()) {
761+
if (IsNormalProcessingMode() && dtm->initialized && MMDoReplication && !am_walsender && !IsBackgroundWorker && !IsAutoVacuumWorkerProcess()) {
761762
MMBeginTransaction();
762763
}
763764
break;
@@ -1190,7 +1191,7 @@ static void MMExecutor(int id, void* work, size_t size)
11901191
{
11911192
TransactionId xid = *(TransactionId*)work;
11921193
char* stmts = (char*)work + 4;
1193-
int rc = SPI_ERROR_TRANSACTION;
1194+
bool finished = false;
11941195

11951196
MMJoinTransaction(xid);
11961197

@@ -1201,9 +1202,10 @@ static void MMExecutor(int id, void* work, size_t size)
12011202

12021203
PG_TRY();
12031204
{
1204-
rc = SPI_execute(stmts, false, 0);
1205+
int rc = SPI_execute(stmts, false, 0);
12051206
SPI_finish();
12061207
PopActiveSnapshot();
1208+
finished = true;
12071209
if (rc != SPI_OK_INSERT && rc != SPI_OK_UPDATE && rc != SPI_OK_DELETE) {
12081210
ereport(LOG, (errmsg("Executor %d: failed to apply transaction %u",
12091211
id, xid)));
@@ -1215,9 +1217,11 @@ static void MMExecutor(int id, void* work, size_t size)
12151217
PG_CATCH();
12161218
{
12171219
FlushErrorState();
1218-
if (rc == SPI_ERROR_TRANSACTION) {
1220+
if (!finished) {
12191221
SPI_finish();
1220-
PopActiveSnapshot();
1222+
if (ActiveSnapshotSet()) {
1223+
PopActiveSnapshot();
1224+
}
12211225
}
12221226
AbortCurrentTransaction();
12231227
}

contrib/multimaster/receiver_raw.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static volatile sig_atomic_t got_sigterm = false;
4646
static volatile sig_atomic_t got_sighup = false;
4747

4848
/* GUC variables */
49-
static int receiver_idle_time = 1;
49+
static int receiver_idle_time = 0;/*1*/
5050
static bool receiver_sync_mode = false;/*true;*/
5151

5252
/* Worker name */

contrib/multimaster/tests/dtmbench

-434 KB
Binary file not shown.

0 commit comments

Comments
 (0)