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

Commitdc3e86c

Browse files
knizhnikkelvich
authored andcommitted
Avoid hanging on exit in pglogical_receiver
1 parentf8c7308 commitdc3e86c

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

‎multimaster.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,10 +2331,16 @@ void MtmReceiverStarted(int nodeId)
23312331
* Druing recovery we need to open only one replication slot from which node should receive all transactions.
23322332
* Slots at other nodes should be removed
23332333
*/
2334-
MtmReplicationModeMtmGetReplicationMode(intnodeId)
2334+
MtmReplicationModeMtmGetReplicationMode(intnodeId,sig_atomic_tvolatile*shutdown)
23352335
{
23362336
boolrecovery= false;
2337-
if (Mtm->status!=MTM_CONNECTED&&Mtm->status!=MTM_ONLINE) {
2337+
2338+
while (Mtm->status!=MTM_CONNECTED&&Mtm->status!=MTM_ONLINE)
2339+
{
2340+
if (*shutdown)
2341+
{
2342+
returnREPLMODE_EXIT;
2343+
}
23382344
MTM_LOG2("%d: receiver slot mode %s",MyProcPid,MtmNodeStatusMnem[Mtm->status]);
23392345
if (Mtm->status==MTM_RECOVERY) {
23402346
recovery= true;
@@ -2351,7 +2357,6 @@ MtmReplicationMode MtmGetReplicationMode(int nodeId)
23512357
}
23522358
/* delay opening of other slots until recovery is completed */
23532359
MtmSleep(STATUS_POLL_DELAY);
2354-
returnREPLMODE_UNKNOWN;
23552360
}
23562361
if (recovery) {
23572362
MTM_LOG1("Recreate replication slot for node %d after end of recovery",nodeId);

‎multimaster.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ typedef enum
117117

118118
typedefenum
119119
{
120-
REPLMODE_UNKNOWN,/* receiver shouldwait */
120+
REPLMODE_EXIT,/* receiver shouldexit */
121121
REPLMODE_RECOVERED,/* recovery of node is completed so drop old slot and restart replication from the current position in WAL */
122122
REPLMODE_RECOVERY,/* perform recorvery of the node by applying all data from the slot from specified point */
123123
REPLMODE_NORMAL/* normal mode: use existed slot or create new one and start receiving data from it from the specified position */
@@ -245,7 +245,7 @@ extern csn_t MtmAssignCSN(void);
245245
externcsn_tMtmSyncClock(csn_tcsn);
246246
externvoidMtmJoinTransaction(GlobalTransactionId*gtid,csn_tsnapshot);
247247
externvoidMtmReceiverStarted(intnodeId);
248-
externMtmReplicationModeMtmGetReplicationMode(intnodeId);
248+
externMtmReplicationModeMtmGetReplicationMode(intnodeId,sig_atomic_tvolatile*shutdown);
249249
externvoidMtmExecute(void*work,intsize);
250250
externvoidMtmExecutor(intid,void*work,size_tsize);
251251
externvoidMtmSendNotificationMessage(MtmTransState*ts,MtmMessageCodecmd);

‎pglogical_receiver.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ feTimestampDifference(int64 start_time, int64 stop_time,
193193

194194
staticcharconst*constMtmReplicationModeName[]=
195195
{
196+
"exit",
196197
"recovered",/* recovery of node is completed so drop old slot and restart replication from the current position in WAL */
197198
"recovery",/* perform recorvery of the node by applying all data from theslot from specified point */
198199
"normal"/* normal mode: use existed slot or create new one and start receiving data from it from the specified position */
@@ -251,9 +252,10 @@ pglogical_receiver_main(Datum main_arg)
251252
* Druing recovery we need to open only one replication slot from which node should receive all transactions.
252253
* Slots at other nodes should be removed
253254
*/
254-
mode=MtmGetReplicationMode(nodeId);
255-
if (mode==REPLMODE_UNKNOWN) {
256-
continue;
255+
mode=MtmGetReplicationMode(nodeId,&got_sigterm);
256+
if (mode==REPLMODE_EXIT)
257+
{
258+
break;
257259
}
258260
count=Mtm->recoveryCount;
259261

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp