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

Commit 07e3d42

Browse files
committed
stop calling pg_decode_caughtup callback in non-recovery scenarios
1 parent b607f08 commit 07e3d42

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

multimaster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ HTAB* MtmGid2State;
191191
static HTAB* MtmRemoteFunctions;
192192
static HTAB* MtmLocalTables;
193193

194-
static bool MtmIsRecoverySession;
194+
bool MtmIsRecoverySession;
195195

196196
static MtmCurrentTrans MtmTx;
197197
static dlist_head MtmLsnMapping = DLIST_STATIC_INIT(MtmLsnMapping);

multimaster.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ extern bool MtmMajorNode;
393393
extern bool MtmBackgroundWorker;
394394
extern char* MtmRefereeConnStr;
395395
extern bool MtmEnforceLocalTx;
396+
extern bool MtmIsRecoverySession;
396397

397398

398399
extern void MtmArbiterInitialize(void);

pglogical_output.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,17 @@ pg_decode_caughtup(LogicalDecodingContext *ctx)
441441
{
442442
PGLogicalOutputData* data = (PGLogicalOutputData*)ctx->output_plugin_private;
443443

444-
if (data->api) {
444+
/*
445+
* MtmOutputPluginPrepareWrite send some bytes to downstream,
446+
* so we must avoid calling it in normal (non-recovery) situation.
447+
*
448+
* It's dirty hack to use MtmIsRecoverySession here and better to
449+
* provide also filter-like callback, but we plan to migrate to native
450+
* output plugin, so this code should anyway go away during next
451+
* release.
452+
*/
453+
if (data->api && MtmIsRecoverySession)
454+
{
445455
MtmOutputPluginPrepareWrite(ctx, true, true);
446456
data->api->write_caughtup(ctx->out, data, ctx->reader->EndRecPtr);
447457
MtmOutputPluginWrite(ctx, true, true);

0 commit comments

Comments
 (0)