Re: Event trigger bugs (was Re: Repeated crashes in GENERATED ... AS IDENTITY tests)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Event trigger bugs (was Re: Repeated crashes in GENERATED ... AS IDENTITY tests)
Date: 2018-04-20 20:54:13
Message-ID: 19285.1524257653@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Hence, two questions:
> * Should EventTriggerTableRewrite do
> if (!currentEventTriggerState ||
> currentEventTriggerState->commandCollectionInhibited)
> return;
> like most of the other functions, or should it just check for null
> currentEventTriggerState?

After closer inspection I've concluded that it should not look
at commandCollectionInhibited; that disables collection of some
data, but it's not related to whether we ought to fire triggers,
AFAICS.

> * Of the three other callers of EventTriggerCommonSetup, only one
> has such a guard now. But aren't EventTriggerDDLCommandStart and
> EventTriggerDDLCommandEnd equally vulnerable to this type of race
> condition? What should they check exactly? Perhaps
> EventTriggerCommonSetup itself should check this?

And the answer here is that DDLCommandStart must fire regardless of the
existence of currentEventTriggerState, because we don't set that up when
there are only ddl_command_start triggers. But it seems like
EventTriggerDDLCommandEnd should quit if it's not set up. That function
itself wouldn't crash, but presumably the called triggers would call
pg_event_trigger_ddl_commands which would fail. Better to pretend the
triggers aren't active yet.

(I see Andrew Gierth came to the same conclusion.)

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan Rudenberg 2018-04-20 22:24:54 Re: [sqlsmith] Unpinning error in parallel worker
Previous Message Bruce Momjian 2018-04-20 20:49:08 Re: PostgreSQL's handling of fsync() errors is unsafe and risks data loss at least on XFS