Re: Placement of InvokeObjectPostAlterHook calls

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Placement of InvokeObjectPostAlterHook calls
Date: 2017-01-10 16:05:56
Message-ID: CA+TgmoYQQyxjgPb_kzK32BTEjNC8XE7GSnxTKww6BK5RKQQucQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 6, 2017 at 12:53 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> While reviewing Etsuro-san's patch to force replanning after FDW option
> changes, I noticed that there is a great lack of consistency about where
> InvokeObjectPostAlterHook calls have been placed relative to other actions
> such as forced relcache invals. I wonder exactly what expectations a
> post-alter hook function could have about cache coherency, or indeed if
> there's any clarity at all about what such a hook might do. For instance,
> it looks to me like the hook would generally need to do a
> CommandCounterIncrement in order to be able to "see" the update it's being
> called for, and I'm unsure that that would be safe at every call site.
> Is that supposed to be allowed, or are we expecting that object access
> hooks are only going to do open-loop actions that don't rely on the
> details of the change?

I remember working pretty hard to make this consistent when that code
went in. In particular, I think the rule I tried to follow was to
place the hooks just after the code that injects dependencies. I
don't know whether the inconsistencies you're seeing are due to (1)
that being a poor rule of thumb, (2) that rule of thumb not being
consistently followed at the time the original patch was committed, or
(3) subsequent drift.

> I suppose this fits in well with our grand tradition of not documenting
> hooks at all, but for a set of hooks as invasive as these are, I think
> we ought to do better.

I would personally be in favor of documenting all of our hooks,
including these. That's a lot of work and I don't have time to do it
real soon, but I think it's a worthwhile goal and I'd be willing to
contribute to the effort. I think they ought to be documented in the
SGML documentation near other things that pertain to server
extensibility. However, I'm pretty sure you've shot down these kinds
of ideas in the past. If you've revised your opinion, swell.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-01-10 16:07:45 Re: Off-by-one oddity in minval for decreasing sequences
Previous Message Kevin Grittner 2017-01-10 16:02:02 Re: RustgreSQL