Skip to content

Commit 017dec7

Browse files
author
Commitfest Bot
committed
[CF 5903] v2 - Invalid pointer access in logical decoding after error
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5903 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CALDaNm13ggU-HzAsD8RCEd5ZE=nDCC8WGdabHDZrqNzum6rb8g@mail.gmail.com Author(s): vigneshwaran C
2 parents f8f4afe + f9e679b commit 017dec7

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/backend/replication/pgoutput/pgoutput.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,19 @@ parse_output_parameters(List *options, PGOutputData *data)
426426
errmsg("option \"%s\" missing", "publication_names"));
427427
}
428428

429+
/*
430+
* Memory context reset callback for clearing the cached relation info.
431+
*/
432+
static void
433+
cache_context_callback(void *arg)
434+
{
435+
if (RelationSyncCache)
436+
{
437+
hash_destroy(RelationSyncCache);
438+
RelationSyncCache = NULL;
439+
}
440+
}
441+
429442
/*
430443
* Initialize this plugin
431444
*/
@@ -435,6 +448,7 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
435448
{
436449
PGOutputData *data = palloc0(sizeof(PGOutputData));
437450
static bool publication_callback_registered = false;
451+
MemoryContextCallback *mcallback;
438452

439453
/* Create our memory context for private allocations. */
440454
data->context = AllocSetContextCreate(ctx->context,
@@ -449,6 +463,10 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
449463
"logical replication publication list context",
450464
ALLOCSET_SMALL_SIZES);
451465

466+
mcallback = palloc0(sizeof(MemoryContextCallback));
467+
mcallback->func = cache_context_callback;
468+
MemoryContextRegisterResetCallback(data->cachectx, mcallback);
469+
452470
ctx->output_plugin_private = data;
453471

454472
/* This plugin uses binary protocol. */

0 commit comments

Comments
 (0)