Content-Length: 291794 | pFad | http://github.com/postgrespro/postgres_cluster/commit/e6c75099d21cc6e4e873fb68c016306ea1963250

30 Correctly handle lock failure in MtmLock · postgrespro/postgres_cluster@e6c7509 · GitHub
Skip to content

Commit e6c7509

Browse files
knizhnikkelvich
authored andcommitted
Correctly handle lock failure in MtmLock
1 parent 00bdad3 commit e6c7509

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

multimaster.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,19 +317,22 @@ void MtmLock(LWLockMode mode)
317317
atexit(MtmReleaseLocks);
318318
MtmAtExitHookRegistered = true;
319319
}
320-
if (mode == LW_EXCLUSIVE || MtmLockCount != 0) {
321-
if (MtmLockCount++ != 0) {
322-
Assert(Mtm->lastLockHolder == MyProcPid);
323-
return;
324-
}
320+
if (MtmLockCount != 0) {
321+
Assert(Mtm->lastLockHolder == MyProcPid);
322+
MtmLockCount += 1;
323+
return;
325324
}
326325
start = MtmGetSystemTime();
327326
LWLockAcquire((LWLockId)&Mtm->locks[MTM_STATE_LOCK_ID], mode);
328327
stop = MtmGetSystemTime();
329328
if (stop > start + MSEC_TO_USEC(MtmHeartbeatSendTimeout)) {
330329
MTM_LOG1("%d: obtaining %s lock takes %lld microseconds", MyProcPid, (mode == LW_EXCLUSIVE ? "exclusive" : "shared"), stop - start);
331330
}
332-
Mtm->lastLockHolder = MyProcPid;
331+
if (mode == LW_EXCLUSIVE) {
332+
Assert(MtmLockCount == 0);
333+
Mtm->lastLockHolder = MyProcPid;
334+
MtmLockCount = 1;
335+
}
333336
}
334337

335338
void MtmUnlock(void)

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres_cluster/commit/e6c75099d21cc6e4e873fb68c016306ea1963250

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy