Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit dd9f6dc

Browse files
committed
restart walsender on recevery_count increment
1 parent 47b18b8 commit dd9f6dc

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

src/include/pglogical_output.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ typedef struct MtmDecoderPrivate
4747
{
4848
bool is_recovery;
4949
bool recovery_done;
50+
int recovery_count;
5051
int64 session_id;
5152
MtmConfig *cfg;
5253
} MtmDecoderPrivate;

src/pglogical_output.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838

3939
#include "storage/ipc.h"
4040

41+
#include "tcop/tcopprot.h"
42+
4143
#include "utils/builtins.h"
4244
#include "utils/catcache.h"
4345
#include "utils/guc.h"
@@ -53,6 +55,7 @@
5355

5456
#include "multimaster.h"
5557
#include "logger.h"
58+
#include "state.h"
5659

5760
extern void _PG_output_plugin_init(OutputPluginCallbacks *cb);
5861

@@ -464,6 +467,17 @@ pg_decode_caughtup(LogicalDecodingContext *ctx)
464467
PGLogicalOutputData *data = (PGLogicalOutputData *) ctx->output_plugin_private;
465468
MtmDecoderPrivate *hooks_data = (MtmDecoderPrivate *) data->hooks.hooks_private_data;
466469

470+
471+
if (hooks_data->recovery_count != MtmGetRecoveryCount())
472+
{
473+
mtm_log(LOG, "exiting due to disabled status");
474+
if (whereToSendOutput == DestRemote)
475+
whereToSendOutput = DestNone;
476+
477+
proc_exit(0);
478+
abort(); /* keep the compiler quiet */
479+
}
480+
467481
/*
468482
* MtmOutputPluginPrepareWrite send some bytes to downstream,
469483
* so we must avoid calling it in normal (non-recovery) situation.

src/pglogical_proto.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ MtmReplicationStartupHook(struct PGLogicalStartupHookArgs* args)
721721
hooks_data->recovery_done = false;
722722
hooks_data->is_recovery = false;
723723
hooks_data->cfg = MtmLoadConfig();
724+
hooks_data->recovery_count = MtmGetRecoveryCount();
724725

725726
foreach(param, args->in_params)
726727
{

src/state.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ MtmStateProcessEvent(MtmEvent ev, bool locked)
394394
{
395395
case MTM_CLIQUE_DISABLE:
396396
BIT_CLEAR(mtm_state->enabled_mask, Mtm->my_node_id - 1);
397-
mtm_state->recovery_count++; /* this will restart replication connection */
397+
// mtm_state->recovery_count++; /* this will restart replication connection */
398398
break;
399399

400400
case MTM_REMOTE_DISABLE:
@@ -413,7 +413,7 @@ MtmStateProcessEvent(MtmEvent ev, bool locked)
413413
case MTM_RECOVERY_FINISH2:
414414
{
415415
mtm_state->recovered = true;
416-
mtm_state->recovery_count++; /* this will restart replication connection */
416+
// mtm_state->recovery_count++; /* this will restart replication connection */
417417
mtm_state->recovery_slot = 0;
418418
}
419419
break;

0 commit comments

Comments
 (0)