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

Commit861e9e4

Browse files
committed
Don't repeatedly register cache callbacks in pgoutput plugin.
Multiple cycles of starting up and shutting down the plugin within asingle session would eventually lead to "out of relcache_callback_listslots", because pgoutput_startup blindly re-registered its cachecallbacks each time. Fix it to register them only once, as all otherusers of cache callbacks already take care to do.This has been broken all along, so back-patch to all supported branches.Shi YuDiscussion:https://postgr.es/m/OSZPR01MB631004A78D743D68921FFAD3FDA79@OSZPR01MB6310.jpnprd01.prod.outlook.com
1 parent226da3d commit861e9e4

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

‎src/backend/replication/pgoutput/pgoutput.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
182182
boolis_init)
183183
{
184184
PGOutputData*data=palloc0(sizeof(PGOutputData));
185+
staticboolpublication_callback_registered= false;
185186

186187
/* Create our memory context for private allocations. */
187188
data->context=AllocSetContextCreate(ctx->context,
@@ -226,9 +227,18 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
226227
/* Init publication state. */
227228
data->publications=NIL;
228229
publications_valid= false;
229-
CacheRegisterSyscacheCallback(PUBLICATIONOID,
230-
publication_invalidation_cb,
231-
(Datum)0);
230+
231+
/*
232+
* Register callback for pg_publication if we didn't already do that
233+
* during some previous call in this process.
234+
*/
235+
if (!publication_callback_registered)
236+
{
237+
CacheRegisterSyscacheCallback(PUBLICATIONOID,
238+
publication_invalidation_cb,
239+
(Datum)0);
240+
publication_callback_registered= true;
241+
}
232242

233243
/* Initialize relation schema cache. */
234244
init_rel_sync_cache(CacheMemoryContext);
@@ -636,8 +646,10 @@ static void
636646
init_rel_sync_cache(MemoryContextcachectx)
637647
{
638648
HASHCTLctl;
649+
staticboolrelation_callbacks_registered= false;
639650
MemoryContextold_ctxt;
640651

652+
/* Nothing to do if hash table already exists */
641653
if (RelationSyncCache!=NULL)
642654
return;
643655

@@ -655,10 +667,16 @@ init_rel_sync_cache(MemoryContext cachectx)
655667

656668
Assert(RelationSyncCache!=NULL);
657669

670+
/* No more to do if we already registered callbacks */
671+
if (relation_callbacks_registered)
672+
return;
673+
658674
CacheRegisterRelcacheCallback(rel_sync_cache_relation_cb, (Datum)0);
659675
CacheRegisterSyscacheCallback(PUBLICATIONRELMAP,
660676
rel_sync_cache_publication_cb,
661677
(Datum)0);
678+
679+
relation_callbacks_registered= true;
662680
}
663681

664682
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp