Re: More parallel pg_dump bogosities

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: More parallel pg_dump bogosities
Дата
Msg-id 21154.1535392691@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: More parallel pg_dump bogosities  (Stephen Frost <sfrost@snowman.net>)
Ответы Re: More parallel pg_dump bogosities  (Stephen Frost <sfrost@snowman.net>)
Re: More parallel pg_dump bogosities  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Stephen Frost <sfrost@snowman.net> writes:
> * Tom Lane (tgl@sss.pgh.pa.us) wrote:
>> And lastly, the ROW SECURITY items are ready because they are not marked
>> with any dependency at all, none, nada.  This seems bad.  In principle
>> it could mean that parallel restore would try to emit "ALTER TABLE ENABLE
>> ROW LEVEL SECURITY" before it's created the table :-(.  I think that in
>> practice that can't happen today, because CREATE TABLE commands get
>> emitted before we've switched into parallel restore mode at all.  But it's
>> definitely possible that ENABLE ROW LEVEL SECURITY could be emitted before
>> we've restored the table's data.  Won't that break things?

> We certainly wouldn't want the ROW SECURITY items to be emitted before
> the table itself, that wouldn't work.  Emitting ENABLE RLS before
> restoring the table's data shouldn't actually break anything though as
> the owner of the table (which is who we're restoring the data as,
> at that point, right?) will bypass RLS.

Hmm.  We'd typically be running a restore either as superuser or as the
table owner ...

> Now, if what's actually set is
> FORCE RLS, then we may have an issue if that is emitted before the table
> data since that would cause RLS to be in effect even if we're the owner
> of the table.

... but if FORCE RLS is applied to the table, we gotta problem anyway,
because that command is included right with the initial table creation.
Once the ENABLE comes out, inserts will fail, because there are no
policies yet (those *do* have table dependencies that get moved to
point at the TABLE DATA).

So it's a bug all right, but a sufficiently corner-case one that it's
not too surprising it hasn't been reported.  Even though the ENABLE RLS
item is "ready to restore", it'll still be at the end of the work list,
so you'd need a very high parallel worker count to have much chance of
it coming out before the table's data item gets processed.

>> I think this is easy enough to fix, just force a dependency on the table
>> to be attached to a ROW SECURITY item; but I wanted to confirm my
>> conclusion that we need one.

> I do think we should have one.

I'll do that, but ...

> In an ideal world, I think we'd want:

> CREATE TABLE
> TABLE DATA
> ENABLE RLS
> ADD RLS POLICIES
> GRANT RIGHTS

... as things stand, even with this fix, a parallel restore will emit
CREATE POLICY and ENABLE RLS commands in an unpredictable order.  Not sure
how much it matters, though.  The GRANTs should come out last anyway.

            regards, tom lane


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

Предыдущее
От: Stephen Frost
Дата:
Сообщение: Re: More parallel pg_dump bogosities
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] Proposal to add work_mem option to postgres_fdw module