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 1nvZHA-0007Uk-H9 for pgsql-hackers@arkaria.postgresql.org; Mon, 30 May 2022 06:53:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nvZH9-0003tR-1m for pgsql-hackers@arkaria.postgresql.org; Mon, 30 May 2022 06:53:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nvZH8-0003tH-MY for pgsql-hackers@lists.postgresql.org; Mon, 30 May 2022 06:53:14 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nvZH1-000244-QV for pgsql-hackers@lists.postgresql.org; Mon, 30 May 2022 06:53:14 +0000 Received: by mail-pl1-x636.google.com with SMTP id n18so9518002plg.5 for ; Sun, 29 May 2022 23:53:07 -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=u+2c7pevaTY9A8o3TTyJuLfoa3jY4KGD3/SiA+IJC5s=; b=i6B0O3Y2WKg2IrxbsIdjlo0AUh7JYMcc/lGFDEMwObjciHfnUOflq2DLK7pE6kMgE5 /D4mCloZJ3GWF9qNHyW4WDKBuiEBk+k9Z7Shy2zPyMgtIotX6TZhz/eOlCLaM1bqC8Tk G6n7lnbakl2zKFW2kxbrrh2I8NinvpmeRG6z9OtDZeXd4P1vb/vXV0+ugOqdcX3l1jwS cFMQ8FcS9irma99SeX7iP7BIg03Z76MzQ8bzZH0I2lR306HXII5k0o+7cLRVCPp0ktDA YeOVaaFSiIscEaQhIGpVj9utHvdgnGHBIsYzRzyA3OIBYcH7V5tGOfGlSVOxfDA2a3Zv wb8g== 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=u+2c7pevaTY9A8o3TTyJuLfoa3jY4KGD3/SiA+IJC5s=; b=XJwTWPvtNCBm7z1t6wPWEs8WzTsHUTQk3lTYsbGnGPoVXQL9expPzkfNEAuEUCKjmw PQ78Winz+TkVGDLah0DNsPRaFOuMSrmfLOyWeh453T+zXLaXvNTS3/f332G/diK7G2U5 eOTs2c0ABgi47I9tjNKjybD7o9bqSNFYdQ9x0SsbIF9MT6DlzZlCdQMps0NFiVc9zS+n 91GjNVUr+oLQmaGwAlcDUI3nOv5tW0GE2Zd5SqbEWYRVHuOoMcyeHoZMojxJP5jf6xez V8G1CMDmpltFi0jm/wBKxE3eWpFbJ5JlgPZNQFutyn3GHlQKz8U/peRaCfavIohAGmhu IYPA== X-Gm-Message-State: AOAM533/ZB/fl8gKelGPlkncdf2zY2WfT5pIds8YRJ45sUvQQ4czabi3 dsT/qILF3OAgcB1Gi/EzPrkJkCVhl+0305RJvnk= X-Google-Smtp-Source: ABdhPJzf6Wni2o0LCaWnKWlVVtugYCEX3EGBQqSL3RiTSX7Krqf1IIyI8cv3nm+bUJyxKfifKmTkyl/X0uwsauAVLpk= X-Received: by 2002:a17:902:c40a:b0:163:d38e:3049 with SMTP id k10-20020a170902c40a00b00163d38e3049mr5352859plk.87.1653893585513; Sun, 29 May 2022 23:53:05 -0700 (PDT) MIME-Version: 1.0 References: <202203162206.7spggyktx63e@alvherre.pgsql> In-Reply-To: From: Masahiko Sawada Date: Mon, 30 May 2022 15:52:29 +0900 Message-ID: Subject: Re: Support logical replication of DDLs To: Amit Kapila Cc: Zheng Li , 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 11:03 AM Amit Kapila wrot= e: > > 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 applicatio= n > > > 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]. > Right. So I'm inclined to think that deparsing approach is better from this point as well as the point mentioned by =C3=81lvaro before[1]. Regards, [1] https://www.postgresql.org/message-id/202204081134.6tcmf5cxl3sz%40alvhe= rre.pgsql --=20 Masahiko Sawada EDB: https://www.enterprisedb.com/