Re: More parallel pg_dump bogosities
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stephen Frost <sfrost@snowman.net>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2018-08-27T17:58:11Z
Lists: 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
Commits
-
Make pg_restore's identify_locking_dependencies() more bulletproof.
- e2841d399a89 10.6 landed
- e0a0cc28d082 12.0 landed
- aac21f11df0d 9.5.15 landed
- 97aa524f18c0 9.6.11 landed
- 49841edcc644 11.0 landed
-
Code review for pg_dump's handling of ALTER INDEX ATTACH PARTITION.
- 8cff4f5348d0 12.0 landed
- 18f6258e5ee8 11.0 landed
-
Fix missing dependency for pg_dump's ENABLE ROW LEVEL SECURITY items.
- cbdca00bef59 12.0 landed
- c5e235ff8ad0 11.0 landed
- 3998e55af050 9.5.15 landed
- 173df4cd36df 9.6.11 landed
- 0f3dd76f527d 10.6 landed