Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit74fa53c

Browse files
knizhnikkelvich
authored andcommitted
Fix race condition in MtmUnlock
1 parent26ce1b8 commit74fa53c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

‎bgwpool.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include"tcop/pquery.h"
1414

1515
#include"bgwpool.h"
16+
#include"multimaster.h"
1617

1718
boolMtmIsLogicalReceiver;
1819
intMtmMaxWorkers;
@@ -32,6 +33,8 @@ static void BgwPoolMainLoop(BgwPool* pool)
3233
void*work;
3334
staticPortalDatafakePortal;
3435

36+
MTM_ELOG(LOG,"Start background worker %d, shutdown=%d",MyProcPid,pool->shutdown);
37+
3538
MtmIsLogicalReceiver= true;
3639
MtmPool=pool;
3740

@@ -48,7 +51,7 @@ static void BgwPoolMainLoop(BgwPool* pool)
4851
while (true) {
4952
PGSemaphoreLock(&pool->available);
5053
SpinLockAcquire(&pool->lock);
51-
if (pool->shutdown) {
54+
if (pool->shutdown) {
5255
break;
5356
}
5457
size=*(int*)&pool->queue[pool->head];
@@ -83,6 +86,7 @@ static void BgwPoolMainLoop(BgwPool* pool)
8386
SpinLockRelease(&pool->lock);
8487
}
8588
SpinLockRelease(&pool->lock);
89+
MTM_ELOG(LOG,"Shutdown background worker %d",MyProcPid);
8690
}
8791

8892
voidBgwPoolInit(BgwPool*pool,BgwPoolExecutorexecutor,charconst*dbname,charconst*dbuser,size_tqueueSize,size_tnWorkers)

‎multimaster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ void MtmUnlock(void)
338338
Assert(Mtm->lastLockHolder==MyProcPid);
339339
return;
340340
}
341-
LWLockRelease((LWLockId)&Mtm->locks[MTM_STATE_LOCK_ID]);
342341
Mtm->lastLockHolder=0;
342+
LWLockRelease((LWLockId)&Mtm->locks[MTM_STATE_LOCK_ID]);
343343
}
344344

345345
voidMtmLockNode(intnodeId,LWLockModemode)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp