Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nuPJu-0002Kq-Im for pgsql-hackers@arkaria.postgresql.org; Fri, 27 May 2022 02:03:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nuPJt-0008RE-Cc for pgsql-hackers@arkaria.postgresql.org; Fri, 27 May 2022 02:03:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nuPJt-0008R5-3E for pgsql-hackers@lists.postgresql.org; Fri, 27 May 2022 02:03:17 +0000 Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nuPJq-0000As-Gn for pgsql-hackers@lists.postgresql.org; Fri, 27 May 2022 02:03:16 +0000 Received: by mail-yb1-xb2a.google.com with SMTP id x137so5707857ybg.5 for ; Thu, 26 May 2022 19:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=2mEA/uhANUUhb2AOp8h6vwKTJmE1XK+zRzzrv5qc4f4=; b=NHxgD62YnuA/0cLg/6Rwb6hwubg1QusFeGbsYL0AZ4gl83NOTle3UQKWQVKRWuVJcI i/4W/vhRDjjkrXO/FTKleFLjp7OjeOGmMx9ioCkowb8BEMGqTpUiOzfeApUrnCy8MGyD 4Rnbl2ZHrbSwexxmutIbyGonMCxhoNKWVaatwZraDUkBYTorSTBkmfbrnWd6rOU0hPWe k0zigHNw9uv2EEy3CqJxWoa4OeoWaIouYHNbOQESwqZotwl277TOFNgd3XQeUvx1jola pSuqzPsvecG6W3BJfwMASu4RUapotWlTJynDfVWE7IRViHNNsG7PlgtYt1mM8dB33LB4 r/JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=2mEA/uhANUUhb2AOp8h6vwKTJmE1XK+zRzzrv5qc4f4=; b=pjSFwJrvxdr0cnTJ3apcVXvrgCeejz9iSA0xc08QWkcrKexyZ8COjFBXLcrQ68XVMX W3poU1j6LN6A7v7Xo+f2/otATVVNNVeZaLbds5DZUrrMwkVaGrpWQ7BvqyQ1XS4y4ET3 3KStor7w+LoIfPw4GV7Dmy/vPw8a5V9TzhILJ6npgU51T5ikwx920eBhV7vObbZOfiv6 TIxpw/kJTAN8XZAnYCgLg54rzJYYjTNeeSzrD9e72uHTMZtUEQTSQdr1UoxHj84sImkK cU5KRvGU9qij2crF2z0Zhc2Q2JX/ecG9oy5o4SO70oZ9bQGq65ocKcAyiylsG7F2IMoF EI1w== X-Gm-Message-State: AOAM533CdaFt8fCisAxoSno1GymQClEiQHYshNhEnf0HJBSkzfofGPBS NpvG2ocZjd36EKOlHePBrnyfCse6CUWv8zcJHGg= X-Google-Smtp-Source: ABdhPJyG2zEWulDDcoQCBVa/0G4C6LNIEj/vid5pwzCKU2NPBoYlJ4KNoT4Ok3e2cqb2nrByLEF90rfW3V/pgqtyw54= X-Received: by 2002:a25:2d6c:0:b0:657:efd7:4da1 with SMTP id s44-20020a252d6c000000b00657efd74da1mr3773342ybe.594.1653616993585; Thu, 26 May 2022 19:03:13 -0700 (PDT) MIME-Version: 1.0 References: <202203162206.7spggyktx63e@alvherre.pgsql> In-Reply-To: From: Amit Kapila Date: Fri, 27 May 2022 07:33:05 +0530 Message-ID: Subject: Re: Support logical replication of DDLs To: Zheng Li Cc: Masahiko Sawada , Japin Li , Alvaro Herrera , Dilip Kumar , rajesh singarapu , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, May 27, 2022 at 3:49 AM Zheng Li wrote: > > Hi Masahiko, > > > Thank you for updating the patches! > > > > I've not looked at these patches in-depth yet but with this approach, > > what do you think we can handle the DDL syntax differences between > > major versions? DDL syntax or behavior could be changed by future > > changes and I think we need to somehow deal with the differences. For > > > example, if the user uses logical replication for major version > > upgrade, the publisher is older than the subscriber. We might have to > > rewrite the DDL before applying to the subscriber because the DDL > > executed on the publisher no longer work on a new PostgreSQL version > > I don't think we will allow this kind of situation to happen in the > first place for > backward compatibility. If a DDL no longer works on a new version of > PostgreSQL, the user will have to change the application code as well. > So even if it happens for > whatever reason, we could either > 1. fail the apply worker and let the user fix such DDL because they'll > have to fix the application code anyway when this happens. > 2. add guard rail logic in the apply worker to automatically fix such > DDL if possible, knowing the version of the source and target. Similar > logic must have been implemented for pg_dump/restore/upgrade. > > > or we might have to add some options to the DDL before the application > > in order to keep the same behavior. This seems to require a different > > solution from what the patch does for the problem you mentioned such > > > as "DDL involving multiple tables where only some tables are > > replicated=E2=80=9D. > > First of all, this case can only happen when the customer chooses to > only replicate a subset of the tables in a database in which case > table level DDL replication is chosen instead of database level DDL > replication (where all tables > and DDLs are replicated). I think the solution would be: > 1. make best effort to detect such DDLs on the publisher and avoid > logging of such DDLs in table level DDL replication. > 2. apply worker will fail to replay such command due to missing > objects if such DDLs didn't get filtered on the publisher for some > reason. This should be rare and I think it's OK even if it happens, > we'll find out > why and fix it. > FWIW, both these cases could be handled with the deparsing approach, and the handling related to the drop of multiple tables where only a few are published is already done in the last POC patch shared by Ajin [1]. [1] - https://www.postgresql.org/message-id/CAFPTHDaBodoZ5c7U1uyokbvq%2BzUv= hJ4ps-7H66nHGw45UnO0OQ%40mail.gmail.com --=20 With Regards, Amit Kapila.