pgsql: Fix relation leak for subscribers firing triggers in logical rep

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема pgsql: Fix relation leak for subscribers firing triggers in logical rep
Дата
Msg-id E1lZQMB-0007qK-0J@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix relation leak for subscribers firing triggers in logical replication

Creating a trigger on a relation to which an apply operation is
triggered would cause a relation leak once the change gets committed,
as the executor would miss that the relation needs to be closed
beforehand.  This issue got introduced with the refactoring done in
1375422c, where it becomes necessary to track relations within
es_opened_result_relations to make sure that they are closed.

We have discussed using ExecInitResultRelation() coupled with
ExecCloseResultRelations() for the relations in need of tracking by the
apply operations in the subscribers, which would simplify greatly the
opening and closing of indexes, but this requires a larger rework and
reorganization of the worker code, particularly for the tuple routing
part.  And that's not really welcome post feature freeze.  So, for now,
settle down to the same solution as TRUNCATE which is to fill in
es_opened_result_relations with the relation opened, to make sure that
ExecGetTriggerResultRel() finds them and that they get closed.

The code is lightly refactored so as a relation is not registered three
times for each DML code path, making the whole a bit easier to follow.

Reported-by: Tang Haiying, Shi Yu, Hou Zhijie
Author: Amit Langote, Masahiko Sawada, Hou Zhijie
Reviewed-by: Amit Kapila, Michael Paquier
Discussion: https://postgr.es/m/OS0PR01MB611383FA0FE92EB9DE21946AFB769@OS0PR01MB6113.jpnprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f3b141c482552a57866c72919007d6481cd59ee3

Modified Files
--------------
src/backend/replication/logical/worker.c | 73 ++++++++++++++++++++------------
1 file changed, 47 insertions(+), 26 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: pgsql: doc: Move parallel_leader_participation to its correct category
Следующее
От: Andrew Dunstan
Дата:
Сообщение: pgsql: Make PostgresNode version aware