Skip to content

Commit 681372d

Browse files
knizhnikkelvich
authored andcommitted
Ignore LSN of prepared transactions
1 parent f8ab676 commit 681372d

File tree

2 files changed

+34
-13
lines changed

2 files changed

+34
-13
lines changed

multimaster.c

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,26 +312,32 @@ void MtmReleaseLocks(void)
312312
*/
313313
void MtmLock(LWLockMode mode)
314314
{
315-
timestamp_t start, stop;
316315
if (!MtmAtExitHookRegistered) {
317316
atexit(MtmReleaseLocks);
318317
MtmAtExitHookRegistered = true;
319318
}
320319
if (MtmLockCount != 0) {
321320
Assert(Mtm->lastLockHolder == MyProcPid);
322321
MtmLockCount += 1;
323-
return;
324322
}
325-
start = MtmGetSystemTime();
326-
LWLockAcquire((LWLockId)&Mtm->locks[MTM_STATE_LOCK_ID], mode);
327-
stop = MtmGetSystemTime();
328-
if (stop > start + MSEC_TO_USEC(MtmHeartbeatSendTimeout)) {
329-
MTM_LOG1("%d: obtaining %s lock takes %lld microseconds", MyProcPid, (mode == LW_EXCLUSIVE ? "exclusive" : "shared"), stop - start);
330-
}
331-
if (mode == LW_EXCLUSIVE) {
332-
Assert(MtmLockCount == 0);
333-
Mtm->lastLockHolder = MyProcPid;
334-
MtmLockCount = 1;
323+
else
324+
{
325+
#if DEBUG_LEVEL > 1
326+
timestamp_t start, stop;
327+
start = MtmGetSystemTime();
328+
#endif
329+
LWLockAcquire((LWLockId)&Mtm->locks[MTM_STATE_LOCK_ID], mode);
330+
#if DEBUG_LEVEL > 1
331+
stop = MtmGetSystemTime();
332+
if (stop > start + MSEC_TO_USEC(MtmHeartbeatSendTimeout)) {
333+
MTM_LOG1("%d: obtaining %s lock takes %lld microseconds", MyProcPid, (mode == LW_EXCLUSIVE ? "exclusive" : "shared"), stop - start);
334+
}
335+
#endif
336+
if (mode == LW_EXCLUSIVE) {
337+
Assert(MtmLockCount == 0);
338+
Mtm->lastLockHolder = MyProcPid;
339+
MtmLockCount = 1;
340+
}
335341
}
336342
}
337343

@@ -527,9 +533,12 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
527533
static timestamp_t totalSleepTime;
528534
static timestamp_t maxSleepTime;
529535
#endif
530-
timestamp_t start = MtmGetSystemTime();
531536
timestamp_t delay = MIN_WAIT_TIMEOUT;
532537
int i;
538+
#if DEBUG_LEVEL > 1
539+
timestamp_t start = MtmGetSystemTime();
540+
#endif
541+
533542
Assert(xid != InvalidTransactionId);
534543

535544
if (!MtmUseDtm) {
@@ -551,9 +560,11 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
551560
if (ts->csn > MtmTx.snapshot) {
552561
MTM_LOG4("%d: tuple with xid=%lld(csn=%lld) is invisible in snapshot %lld",
553562
MyProcPid, (long64)xid, ts->csn, MtmTx.snapshot);
563+
#if DEBUG_LEVEL > 1
554564
if (MtmGetSystemTime() - start > USECS_PER_SEC) {
555565
MTM_ELOG(WARNING, "Backend %d waits for transaction %s (%llu) status %lld usecs", MyProcPid, ts->gid, (long64)xid, MtmGetSystemTime() - start);
556566
}
567+
#endif
557568
MtmUnlock();
558569
return true;
559570
}
@@ -593,10 +604,12 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
593604
MTM_LOG4("%d: tuple with xid=%lld(csn= %lld) is %s in snapshot %lld",
594605
MyProcPid, (long64)xid, ts->csn, invisible ? "rollbacked" : "committed", MtmTx.snapshot);
595606
MtmUnlock();
607+
#if DEBUG_LEVEL > 1
596608
if (MtmGetSystemTime() - start > USECS_PER_SEC) {
597609
MTM_ELOG(WARNING, "Backend %d waits for %s transaction %s (%llu) %lld usecs", MyProcPid, invisible ? "rollbacked" : "committed",
598610
ts->gid, (long64)xid, MtmGetSystemTime() - start);
599611
}
612+
#endif
600613
return invisible;
601614
}
602615
}
@@ -608,7 +621,11 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
608621
}
609622
}
610623
MtmUnlock();
624+
#if DEBUG_LEVEL > 1
611625
MTM_ELOG(ERROR, "Failed to get status of XID %llu in %lld usec", (long64)xid, MtmGetSystemTime() - start);
626+
#else
627+
MTM_ELOG(ERROR, "Failed to get status of XID %llu", (long64)xid);
628+
#endif
612629
return true;
613630
}
614631

@@ -3815,6 +3832,7 @@ bool MtmFilterTransaction(char* record, int size)
38153832
switch (event)
38163833
{
38173834
case PGLOGICAL_PREPARE:
3835+
return false;
38183836
case PGLOGICAL_PRECOMMIT_PREPARED:
38193837
case PGLOGICAL_ABORT_PREPARED:
38203838
gid = pq_getmsgstring(&s);

pglogical_apply.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,9 @@ process_remote_commit(StringInfo in)
649649
lsn_t origin_lsn;
650650
int origin_node;
651651
char gid[MULTIMASTER_MAX_GID_SIZE];
652+
653+
gid[0] = '\0';
654+
652655
/* read event */
653656
event = pq_getmsgbyte(in);
654657
MtmReplicationNodeId = pq_getmsgbyte(in);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy