Re: Catalog/Metadata consistency during changeset extraction from wal - Mailing list pgsql-hackers
From | Amit Kapila |
---|---|
Subject | Re: Catalog/Metadata consistency during changeset extraction from wal |
Date | |
Msg-id | 003501cd5291$b1397240$13ac56c0$@kapila@huawei.com Whole thread Raw |
In response to | Re: Catalog/Metadata consistency during changeset extraction from wal (Robert Haas <robertmhaas@gmail.com>) |
List | pgsql-hackers |
-----Original Message----- From: pgsql-hackers-owner@postgresql.org [mailto:pgsql-hackers-owner@postgresql.org] On Behalf Of Robert Haas Sent: Monday, June 25, 2012 6:39 AM To: Andres Freund Cc: pgsql-hackers@postgresql.org; Florian Pflug; Simon Riggs Subject: Re: [HACKERS] Catalog/Metadata consistency during changeset extraction from wal On Sun, Jun 24, 2012 at 5:11 PM, Andres Freund <andres@2ndquadrant.com> wrote: > There are some interesting problems related to locking and snapshots here. Not > sure if they are resolvable: > > We need to restrict SnapshotNow to represent to the view it had back when the > wal record were currently decoding had. Otherwise we would possibly get wrong > column types and similar. As were working in the past locking doesn't protect > us against much here. I have that (mostly and inefficiently). > > One interesting problem are table rewrites (truncate, cluster, some ALTER > TABLE's) and dropping tables. Because we nudge SnapshotNow to the past view it > had back when the wal record was created we get the old relfilenode. Which > might have been dropped in part of the transaction cleanup... > With most types thats not a problem. Even things like records and arrays > aren't problematic. More interesting cases include VACUUM FULL $systable (e.g. > pg_enum) and vacuum full'ing a table which is used in the *_out function of a > type (like a user level pg_enum implementation). > > The only theoretical way I see against that problem would be to postpone all > relation unlinks untill everything that could possibly read them has finished. > Doesn't seem to alluring although it would be needed if we ever move more > things of SnapshotNow. > > Input/Ideas/Opinions? > Yeah, this is slightly nasty. I'm not sure whether or not there's a > way to make it work. > I had another idea. Suppose decoding happens directly on the primary, > because I'm still hoping there's a way to swing that. Suppose further > that we handle DDL by insisting that (1) any backend which wants to > add columns or change the types of existing columns must first wait > for logical replication to catch up and (2) if a backend which has > added columns or changed the types of existing columns then writes to > the modified table, decoding of those writes will be postponed until > transaction commit. I think that's enough to guarantee that the > decoding process can just use the catalogs as they stand, with plain > old SnapshotNow. What will be the way to make the DDL's wait for logical replication to catch up? One way can be that by looking WAL location till what it has generated logical records. If we do this by holding table level locks (which will be required for DDL's), then other DML's will also get blocked. And If we do this without holding locks and decided to go ahead then there can be other WAL generated by the meantime and can create a problem. Or if there is another way to make DDL's wait? With Regards, Amit Kapila.
pgsql-hackers by date: