Fix pub switchover bug.

This commit is contained in:
totaj
2023-06-07 16:25:57 +08:00
parent 39f999f981
commit 4ed1ca2310
3 changed files with 6 additions and 1 deletions

View File

@ -1084,6 +1084,7 @@ static void KnlTPublicationInit(knl_t_publication_context* publicationCxt)
publicationCxt->publications_valid = false;
publicationCxt->RelationSyncCache = NULL;
publicationCxt->updateConninfoNeeded = false;
publicationCxt->firstTimeSendConninfo = false;
}
static void KnlTUndolauncherInit(knl_t_undolauncher_context* undolauncherCxt)

View File

@ -178,6 +178,7 @@ static void pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *o
if (data->protocol_version >= LOGICALREP_CONNINFO_PROTO_VERSION_NUM) {
t_thrd.publication_cxt.updateConninfoNeeded = true;
}
t_thrd.publication_cxt.firstTimeSendConninfo = true;
CacheRegisterThreadSyscacheCallback(PUBLICATIONOID, publication_invalidation_cb, (Datum)0);
/* Initialize relation schema cache. */
@ -235,7 +236,8 @@ static void pgoutput_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *t
* Send the newest connecttion information to the subscriber,
* when the connection information about the standby changes.
*/
if (t_thrd.publication_cxt.updateConninfoNeeded && ReplconninfoChanged()) {
if ((t_thrd.publication_cxt.updateConninfoNeeded && ReplconninfoChanged()) ||
t_thrd.publication_cxt.firstTimeSendConninfo) {
StringInfoData standbysInfo;
initStringInfo(&standbysInfo);
@ -245,6 +247,7 @@ static void pgoutput_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *t
OutputPluginWrite(ctx, true);
FreeStringInfo(&standbysInfo);
t_thrd.publication_cxt.firstTimeSendConninfo = false;
}
}

View File

@ -3339,6 +3339,7 @@ typedef struct knl_t_publication_context {
/* Map used to remember which relation schemas we sent. */
HTAB* RelationSyncCache;
bool updateConninfoNeeded;
bool firstTimeSendConninfo;
} knl_t_publication_context;
typedef struct knl_t_dms_context {