RE: Table refer leak in logical replication - Mailing list pgsql-hackers

From houzj.fnst@fujitsu.com
Subject RE: Table refer leak in logical replication
Date
Msg-id OS0PR01MB571686F75FBDC219FF3DFF0D94769@OS0PR01MB5716.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Table refer leak in logical replication  ("tanghy.fnst@fujitsu.com" <tanghy.fnst@fujitsu.com>)
Responses RE: Table refer leak in logical replication
Re: Table refer leak in logical replication
List pgsql-hackers
> WARNING: relcache reference leak: relation "xxx" not closed.
>
> Example of the procedure:
> ------publisher------
> create table test (a int primary key);
> create publication pub for table test;
>
> ------subscriber------
> create table test (a int primary key);
> create subscription sub connection 'dbname=postgres' publication pub;
> create function funcA() returns trigger as $$ begin return null; end; $$ language
> plpgsql; create trigger my_trig after insert or update or delete on test for each
> row execute procedure funcA(); alter table test enable replica trigger my_trig;
>
> ------publisher------
> insert into test values (6);
>
> It seems an issue about reference leak. Anyone can fix this?

It seems ExecGetTriggerResultRel will reopen the target table because it cannot find an existing one.
Storing the opened table in estate->es_opened_result_relations seems solves the problem.

Attaching a patch that fix this.
BTW, it seems better to add a testcase for this ?

Best regards,
houzj

Attachment

pgsql-hackers by date:

Previous
From: "tanghy.fnst@fujitsu.com"
Date:
Subject: Table refer leak in logical replication
Next
From: "shiy.fnst@fujitsu.com"
Date:
Subject: RE: Table refer leak in logical replication