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

Commitdc4fb75

Browse files
knizhnikkelvich
authored andcommitted
handle exit of wal-sender
1 parent3cdb373 commitdc4fb75

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

‎multimaster.c

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -864,10 +864,13 @@ void MtmSendNotificationMessage(MtmTransState* ts, MtmMessageCode cmd)
864864

865865
voidMtmJoinTransaction(GlobalTransactionId*gtid,csn_tglobalSnapshot)
866866
{
867-
MtmLock(LW_EXCLUSIVE);
868-
MtmSyncClock(globalSnapshot);
869-
MtmUnlock();
870-
867+
if (globalSnapshot!=INVALID_CSN) {
868+
MtmLock(LW_EXCLUSIVE);
869+
MtmSyncClock(globalSnapshot);
870+
MtmUnlock();
871+
}else {
872+
globalSnapshot=MtmTx.snapshot;
873+
}
871874
if (!TransactionIdIsValid(gtid->xid)) {
872875
/* In case of recovery InvalidTransactionId is passed */
873876
Assert(Mtm->status==MTM_RECOVERY);
@@ -1876,6 +1879,14 @@ void MtmDropNode(int nodeId, bool dropSlot)
18761879
}
18771880
}
18781881
}
1882+
staticvoid
1883+
MtmOnProcExit(intcode,Datumarg)
1884+
{
1885+
if (MtmReplicationNodeId >=0) {
1886+
elog(WARNING,"WAL-sender to %d is terminated",MtmReplicationNodeId);
1887+
MtmOnNodeDisconnect(MtmReplicationNodeId);
1888+
}
1889+
}
18791890

18801891
staticvoid
18811892
MtmReplicationStartupHook(structPGLogicalStartupHookArgs*args)
@@ -1922,13 +1933,17 @@ MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
19221933
elog(NOTICE,"Node %d start logical replication to node %d in normal mode",MtmNodeId,MtmReplicationNodeId);
19231934
}
19241935
MtmUnlock();
1936+
on_proc_exit(MtmOnProcExit,0);
19251937
}
19261938

19271939
staticvoid
19281940
MtmReplicationShutdownHook(structPGLogicalShutdownHookArgs*args)
19291941
{
1930-
elog(WARNING,"Logical replication to node %d is stopped",MtmReplicationNodeId);
1931-
MtmOnNodeDisconnect(MtmReplicationNodeId);
1942+
if (MtmReplicationNodeId >=0) {
1943+
elog(WARNING,"Logical replication to node %d is stopped",MtmReplicationNodeId);
1944+
MtmOnNodeDisconnect(MtmReplicationNodeId);
1945+
MtmReplicationNodeId=-1;/* defuse on_proc_exit hook */
1946+
}
19321947
}
19331948

19341949
staticbool
@@ -2166,7 +2181,8 @@ static bool MtmRunUtilityStmt(PGconn* conn, char const* sql, char **errmsg)
21662181
returnret;
21672182
}
21682183

2169-
voidMtmNoticeReceiver(void*i,constPGresult*res)
2184+
staticvoid
2185+
MtmNoticeReceiver(void*i,constPGresult*res)
21702186
{
21712187
char*notice=PQresultErrorMessage(res);
21722188
char*stripped_notice;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp