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

Commitcef1c9c

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 parent940b547 commitcef1c9c

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

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

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
393393
boolis_init)
394394
{
395395
PGOutputData*data=palloc0(sizeof(PGOutputData));
396+
staticboolpublication_callback_registered= false;
396397

397398
/* Create our memory context for private allocations. */
398399
data->context=AllocSetContextCreate(ctx->context,
@@ -481,9 +482,18 @@ pgoutput_startup(LogicalDecodingContext *ctx, OutputPluginOptions *opt,
481482
/* Init publication state. */
482483
data->publications=NIL;
483484
publications_valid= false;
484-
CacheRegisterSyscacheCallback(PUBLICATIONOID,
485-
publication_invalidation_cb,
486-
(Datum)0);
485+
486+
/*
487+
* Register callback for pg_publication if we didn't already do that
488+
* during some previous call in this process.
489+
*/
490+
if (!publication_callback_registered)
491+
{
492+
CacheRegisterSyscacheCallback(PUBLICATIONOID,
493+
publication_invalidation_cb,
494+
(Datum)0);
495+
publication_callback_registered= true;
496+
}
487497

488498
/* Initialize relation schema cache. */
489499
init_rel_sync_cache(CacheMemoryContext);
@@ -1709,7 +1719,7 @@ pgoutput_origin_filter(LogicalDecodingContext *ctx,
17091719
* Shutdown the output plugin.
17101720
*
17111721
* Note, we don't need to clean the data->context and data->cachectx as
1712-
* they are childcontext of the ctx->context soit will be cleaned up by
1722+
* they are childcontexts of the ctx->context sothey will be cleaned up by
17131723
* logical decoding machinery.
17141724
*/
17151725
staticvoid
@@ -1891,7 +1901,9 @@ static void
18911901
init_rel_sync_cache(MemoryContextcachectx)
18921902
{
18931903
HASHCTLctl;
1904+
staticboolrelation_callbacks_registered= false;
18941905

1906+
/* Nothing to do if hash table already exists */
18951907
if (RelationSyncCache!=NULL)
18961908
return;
18971909

@@ -1906,13 +1918,19 @@ init_rel_sync_cache(MemoryContext cachectx)
19061918

19071919
Assert(RelationSyncCache!=NULL);
19081920

1921+
/* No more to do if we already registered callbacks */
1922+
if (relation_callbacks_registered)
1923+
return;
1924+
19091925
CacheRegisterRelcacheCallback(rel_sync_cache_relation_cb, (Datum)0);
19101926
CacheRegisterSyscacheCallback(PUBLICATIONRELMAP,
19111927
rel_sync_cache_publication_cb,
19121928
(Datum)0);
19131929
CacheRegisterSyscacheCallback(PUBLICATIONNAMESPACEMAP,
19141930
rel_sync_cache_publication_cb,
19151931
(Datum)0);
1932+
1933+
relation_callbacks_registered= true;
19161934
}
19171935

19181936
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp