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

Commitdecf3fe

Browse files
author
Amit Kapila
committed
Fix relation descriptor leak.
We missed closing the relation descriptor while sending changes via theroot of partitioned relations during logical replication.Author: Amit Langote and Mark ZhaoReviewed-by: Amit Kapila and Ashutosh BapatBackpatch-through: 13, where it was introducedDiscussion:https://postgr.es/m/tencent_41FEA657C206F19AB4F406BE9252A0F69C06@qq.comDiscussion:https://postgr.es/m/tencent_6E296D2F7D70AFC90D83353B69187C3AA507@qq.com
1 parent14a608a commitdecf3fe

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
363363
PGOutputData*data= (PGOutputData*)ctx->output_plugin_private;
364364
MemoryContextold;
365365
RelationSyncEntry*relentry;
366+
Relationancestor=NULL;
366367

367368
if (!is_publishable_relation(relation))
368369
return;
@@ -404,7 +405,8 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
404405
if (relentry->publish_as_relid!=RelationGetRelid(relation))
405406
{
406407
Assert(relation->rd_rel->relispartition);
407-
relation=RelationIdGetRelation(relentry->publish_as_relid);
408+
ancestor=RelationIdGetRelation(relentry->publish_as_relid);
409+
relation=ancestor;
408410
/* Convert tuple if needed. */
409411
if (relentry->map)
410412
tuple=execute_attr_map_tuple(tuple,relentry->map);
@@ -425,7 +427,8 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
425427
if (relentry->publish_as_relid!=RelationGetRelid(relation))
426428
{
427429
Assert(relation->rd_rel->relispartition);
428-
relation=RelationIdGetRelation(relentry->publish_as_relid);
430+
ancestor=RelationIdGetRelation(relentry->publish_as_relid);
431+
relation=ancestor;
429432
/* Convert tuples if needed. */
430433
if (relentry->map)
431434
{
@@ -448,7 +451,8 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
448451
if (relentry->publish_as_relid!=RelationGetRelid(relation))
449452
{
450453
Assert(relation->rd_rel->relispartition);
451-
relation=RelationIdGetRelation(relentry->publish_as_relid);
454+
ancestor=RelationIdGetRelation(relentry->publish_as_relid);
455+
relation=ancestor;
452456
/* Convert tuple if needed. */
453457
if (relentry->map)
454458
oldtuple=execute_attr_map_tuple(oldtuple,relentry->map);
@@ -465,6 +469,12 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
465469
Assert(false);
466470
}
467471

472+
if (RelationIsValid(ancestor))
473+
{
474+
RelationClose(ancestor);
475+
ancestor=NULL;
476+
}
477+
468478
/* Cleanup */
469479
MemoryContextSwitchTo(old);
470480
MemoryContextReset(data->context);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp