Re: [BUG v13] Crash with event trigger in extension
От | Jehan-Guillaume de Rorthais |
---|---|
Тема | Re: [BUG v13] Crash with event trigger in extension |
Дата | |
Msg-id | 20200908190759.12405fe5@firost обсуждение исходный текст |
Ответ на | Re: [BUG v13] Crash with event trigger in extension (Alvaro Herrera <alvherre@2ndquadrant.com>) |
Ответы |
Re: [BUG v13] Crash with event trigger in extension
|
Список | pgsql-bugs |
On Tue, 8 Sep 2020 11:33:24 -0300 Alvaro Herrera <alvherre@2ndquadrant.com> wrote: > On 2020-Sep-08, Jehan-Guillaume de Rorthais wrote: > > > It appears that when keeping the event trigger enabled, > > currentEventTriggerState might be initiated multiple times: one for the top > > level "alter extension ... update", then once per DDL query triggering en > > event in the extension update script. I suppose there's no crash because > > the very first currentEventTriggerState initialized at top level is > > overrode by next ones, each being destroyed in their own context. So at the > > end of the extension script, currentEventTriggerState is just destroyed and > > empty. > > Hmm. I spent a lot of time making sure the event trigger thing worked > correctly in reentrant cases, but I don't think the case of execution of > extension scripts was ever considered. So you're right that it might be > broken, since it appears not to be thoroughly tested (if at all). Argh. After some more debugging, I realized I missed the fact that EventTriggerBeginCompleteQuery/EventTriggerEndCompleteQuery were actually stacking allocations using currentEventTriggerState->previous. My bad, sorry for your time. I still have a last question in mind though. While running the bellow scenario, the DDL in the extension do not trigger evt_ext_ddl_fnct. Is it normal/expected? BEGIN; CREATE OR REPLACE FUNCTION _evt_ext_ddl_fnct() RETURNS EVENT_TRIGGER LANGUAGE plpgsql AS $$ DECLARE r record; BEGIN FOR r in SELECT * FROM pg_event_trigger_ddl_commands() LOOP raise notice 'called %: %.%', quote_ident(r.command_tag), quote_ident(r.schema_name), quote_ident(r.object_identity); end loop; END; $$; CREATE EVENT TRIGGER evt_ext_ddl_fnct ON ddl_command_end EXECUTE PROCEDURE _evt_ext_ddl_fnct(); CREATE EXTENSION test_event_trigger VERSION '1.0'; ALTER EXTENSION test_event_trigger UPDATE TO '2.0'; CREATE TABLE test( i int); ROLLBACK; The only output is: NOTICE: called "CREATE EXTENSION": <NULL>.test_event_trigger NOTICE: called "ALTER EXTENSION": <NULL>.test_event_trigger NOTICE: called "CREATE TABLE": public."public.test" Regards,
В списке pgsql-bugs по дате отправления: