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 1nuLpU-0008Ux-0Q for pgsql-hackers@arkaria.postgresql.org; Thu, 26 May 2022 22:19:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nuLpS-0005si-FJ for pgsql-hackers@arkaria.postgresql.org; Thu, 26 May 2022 22:19:38 +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 1nuLpS-0005sZ-4Q for pgsql-hackers@lists.postgresql.org; Thu, 26 May 2022 22:19:38 +0000 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nuLpP-0003qr-Nw for pgsql-hackers@lists.postgresql.org; Thu, 26 May 2022 22:19:37 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-e5e433d66dso3861701fac.5 for ; Thu, 26 May 2022 15:19:35 -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=YfA7NeN8QwrYnJBMcZ0pRfqJDbRzT4m0FXIs1qpGldc=; b=jJMnQLMzRT7AZHYgTf0E6dt3k2wcmkaXRjTaYmG/a7r4weepKa4+5rHhSY2ZYXu9Ba wGWIX/WUiqYu1BEIzxCaeDqG1dKWwPHJwsCbDzwTl5ZPX9P/P/H2C2OqsCWCLXpgkumh oq6qutf6IdN5ZMW9f5nyFgzvYQxGbpE1BK+2brU9MW5QKu0F8NaDU1+i/5utia2I+Od6 //Tf69quO1Hfwnj7kgmuttXeWKInCcCraP/rs2xNUaFzga0RCtnGzvTLX0uEuyNJA618 IDMJJImKBbbvO/yFj6EOT9fuZcV8z2ioqeYZzTP+tyk7SU1yQMIZMiW8xgUvLVB48XOP A78g== 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=YfA7NeN8QwrYnJBMcZ0pRfqJDbRzT4m0FXIs1qpGldc=; b=BmQqewlhq+QLFZeGM5pSg3JNgXmvFXxCiQbzsz4yMvUlnbpXNR/ojTgyPCO2upoWGV pn7iUbzgyobJw0KV10fhrdqZ03jwakjvpML3wKYKreFA1bXzzgtFXvl9VKwCFl4/lD0S CUZHf/bwvNMnjmI27yT0if5ovBtE8wQMEfgsi+u4SQ++eYa6FEUa5Mp45Eur8F97bOKn Pnt8h171Pl/BsWAq29eDnvkkmusUHnTmK4qC7MDAUwR7li1h9ZijKawXA+4Y7CLkKe6N 5DHbmR+e/Ta3wLfGrfTBEmIS0adN3CRwqYNaFhodnKQAW3t/N2dSD0ZjGLxQV63UJHFO ncfA== X-Gm-Message-State: AOAM532nu+KOpu1aWdOlb4hh9sBs8ACuLLHNESDpZ2iT8sVPX4FHg2IT 1UoWy53evhBA0e2aAWHDXEuydC1O8i9QfFULOvY= X-Google-Smtp-Source: ABdhPJzn+Yi4njSoypyb4TWZzMKznwCOkB4xlFalc7HHDR+yap11e1Fe2Rn7HN+jzN9vqcel6UZnzq1AzqjfhWtCDBA= X-Received: by 2002:a05:6870:600d:b0:f2:6c00:4878 with SMTP id t13-20020a056870600d00b000f26c004878mr2604757oaa.249.1653603573418; Thu, 26 May 2022 15:19:33 -0700 (PDT) MIME-Version: 1.0 References: <202203162206.7spggyktx63e@alvherre.pgsql> In-Reply-To: From: Zheng Li Date: Thu, 26 May 2022 18:19:21 -0400 Message-ID: Subject: Re: Support logical replication of DDLs To: Masahiko Sawada Cc: Amit Kapila , 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 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. Regards, Zheng