Re: PgFDW connection invalidation by ALTER SERVER/ALTER USER MAPPING

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: ashutosh(dot)bapat(at)enterprisedb(dot)com
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us, pgsql-hackers(at)postgresql(dot)org, Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp, fcs1(at)poczta(dot)onet(dot)pl
Subject: Re: PgFDW connection invalidation by ALTER SERVER/ALTER USER MAPPING
Date: 2017-07-25 07:04:38
Message-ID: 20170725.160438.121311075.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

At Mon, 24 Jul 2017 10:23:07 +0530, Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com> wrote in <CAFjFpRc_q8wNOe-RDTfRSpC6Pey3AjADAJ4noEiujAthW60K7A(at)mail(dot)gmail(dot)com>
> On Fri, Jul 21, 2017 at 10:39 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com> writes:
> >> On Fri, Jul 21, 2017 at 10:55 AM, Kyotaro HORIGUCHI
> >> <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote:
> >>> The attached patch differs only in this point.
> >
> >> +1. The patch looks good to me.
> >
> > Pushed with a couple additional changes: we'd all missed that the header
> > comment for GetConnection was obsoleted by this change, and the arguments
> > for GetSysCacheHashValue really need to be coerced to Datum. (I think
> > OID to Datum is the same as what the compiler would do anyway, but best
> > not to assume that.)
>
> Thanks and sorry for not noticing the prologue.

Ditto.

> >
> > Back-patching was more exciting than I could wish. It seems that
> > before 9.6, we did not have struct UserMapping storing the OID of the
> > pg_user_mapping row it had been made from. I changed GetConnection to
> > re-look-up that row and get the OID. But that's ugly, and there's a
> > race condition: if user mappings are being added or deleted meanwhile,
> > we might locate a per-user mapping when we're really using a PUBLIC
> > mapping or vice versa, causing the ConnCacheEntry to be labeled with
> > the wrong hash value so that it might not get invalidated properly later.
> > Still, it's significantly better than it was, and that corner case seems
> > unlikely to get hit in practice --- for one thing, you'd have to then
> > revert the mapping addition/deletion before the ConnCacheEntry would be
> > found and used again. I don't want to take the risk of modifying struct
> > UserMapping in stable branches, so it's hard to see a way to make that
> > completely bulletproof before 9.6.
>
> +1.

Agreed.

> --
> Best Wishes,
> Ashutosh Bapat
> EnterpriseDB Corporation
> The Postgres Database Company

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message nikhil.varangaonkar 2017-07-25 07:35:08 BUG #14760: Installation Failed/Interrupted
Previous Message David G. Johnston 2017-07-25 00:43:58 Re: BUG #14759: insert into foreign data partitions fail

Browse pgsql-hackers by date

  From Date Subject
Next Message Victor Drobny 2017-07-25 08:17:23 Re: pg_dump issues
Previous Message Zehra Gül Çabuk 2017-07-25 06:18:29 Postgresql “alter column type” creates an event which contains “temp_table_xxx”