Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wIYCR-008CD4-0u for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Apr 2026 20:41:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wIYCO-008kzW-26 for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Apr 2026 20:41:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wIYCO-008kzE-0j for pgsql-hackers@lists.postgresql.org; Thu, 30 Apr 2026 20:41:28 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wIYCM-00000003ZrD-02KC for pgsql-hackers@lists.postgresql.org; Thu, 30 Apr 2026 20:41:27 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-2b2503753efso13726395ad.0 for ; Thu, 30 Apr 2026 13:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1777581685; cv=none; d=google.com; s=arc-20240605; b=BbeiiZBl2RMIn7TtrQEVpQ8OKaerHba4kbogn8dCR3mbuCKh0tS39c//CxAGO2mag7 E+T3iLqRKtVukDWYO9Te+PuHmA+6I4g3TgSK4yQy/BJ2zONXQxuy72A5DhSp1mmH+G5D A1c/UH2uwaO9EL90qFZ9EqcnbkM+uMYFdeO6LGzvQRsmw8UCEU5jcPHDpcpPVwoefYmy ouGZV+UdBiFMCHgE6ncWYuwFSx99tPYdX0rB+/A7vwhj21HO8cQ0nBbSs7i4BqdIsOh7 V/L/mxiflV/vtnwlsCIkvTXwQt7duMzXV/jYoRu6AcYXscNnhwimUJ6FHJ3T+WFN+FRm DL4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=lxK6ZHA55NwvRlXe4CRXR8u7V2Q2ZZiJK8zC8vc0LiI=; fh=fMVAeY9IXO7IolqraULxpLg246sE0IwkEgsL2l5Zp2g=; b=E8VHJmNVUdknAp+7U0StkPu+9XWVeIPChy+QQStIVIaGQ/5AsypOwlYHDc4W2bpH4N 1+uCcJMbSp0GxXhYifYsJ+AZv70K0gkyhy/Vo+qdDp2WA4ROtmnam35KHRVp/az4iD9c /tn1bgtBjD9Qci2oVs2FZkLGJL/pugZHQ8ANQlTk/D1GowAarT1CAIwL5UmbMmFlrdLW eOeYJbLl2ZBW+u4ZszZFkINciPvIlCXZe/rLFC32GCi+QO+pT/YkcQXWWNlmyXtcidqo 8sbXnmc5nWRnRITQoOtzHEuWtH+ZkBAzd2xId6gbhM1Beey0sSd2LLOGHxFgmi5S51za 8QKg==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777581685; x=1778186485; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lxK6ZHA55NwvRlXe4CRXR8u7V2Q2ZZiJK8zC8vc0LiI=; b=oaEPVRxVzvWX4pxR+nTXVJPVj9gLoa/NZDQk3ckDvJYvU/K9Ew5ztRhpIXU9mCSahx 7gvcrMmnczJ8XT5Rei3sZ0AOZIXiLpgdKcRVnYEtQOtrrNhdFRaYQys/ggs5czjYlnqU IFitkluZUmNktmM76uPkbteLKAq+hX1pwi+hvYb/YY6mF4lIvo8JZC0BmbM3klkpdUVK XQlbSWLXhSP/TsT8aAytmhpuNEVsRLL4jWycWHIEwqGsIMazmK0ouKKp3BAvN/bom+gQ MH7JvFZB6bXEDCJb7ngTznw9T24UMwjCxZUVSFEXh5GxaypKUcJT77ySjIv9HczWIr9B xJrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777581685; x=1778186485; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lxK6ZHA55NwvRlXe4CRXR8u7V2Q2ZZiJK8zC8vc0LiI=; b=Hio+Ch05mkQc/Jy5NTpdcM3a4B3ZGTO/s8gC3qYYUNVngsz4FfagDSUXajbmhTNIOK Jc6mqhNoE4co3mpX8EwxoQVEhR+ZhXTCsKns880dqsI+w4E/APDonQ14jjyMzGs3czC6 QSL3UaP8+wB8G+wtbl1gTdsdsURaNkfAzmpVDwKC8dF5QIuyOyPBNiu6hHRJSgyMzWp6 Xh987cyFFkDLxXz3HMvGhoKt3oAFsgTOIe1T7x7fK1yFA9oGho5UyY6HBmoHu9oMRy5Y BnGnJmG7UFo/DSt9ApGnMyjf1lQbI7pmDRW0hZvkiMN3tFs7+b2ozG0EOcQpDs+w1+pW W9PQ== X-Forwarded-Encrypted: i=1; AFNElJ9e96KFgIxofAb75MlPAlpsRryTf6Dl+arb4ZM+8qVZoKATfE1Q4s6XtSWWwar/TEXqQo/6vtuHhqHdlpCT@lists.postgresql.org X-Gm-Message-State: AOJu0YwRMdXk69Halag5NL+SwEM952uC5kdBTll7jTLxxDqxUG0KIgfW nimGrpdqGy8HSmjcU05kE6uYDa3yg9wfnRxz1R7k+OU6cC5z1Cn4I6L8I7OsFZOU8rOYcqYY1xV 9HXseh8SKSYvO2jsV6oa+sFftpZxGCJQ= X-Gm-Gg: AeBDieuy0MhWBvhRu0u5lVTruLC+1un99VaKjzFvQ0H4WFUlGYueROW+LcKsluwdYyY VmO7QCmjZ14qqguWypS/kEOveIsZRwm/8hv8g7LcDds5tz1UA0QfbmTl5eaSAsgmzBSp9Eu827F 6QwuxxYpJ4HZepUKrRXEBMz9o9FEC4HWd+aZK5r5VWiZ1NJ4e/zr+F3LKW2TJYap2+8aTrac04w IGZVlwgjP8ATfq4MEvhCsUaYOBa0aPwaFKHJmxF2706iBDby4WrUaClg1+PhYjXwfpyrQp0n0aW Red6rgZShE1UYbNN5OZ+npB5ZOBNlCRO90OLFKG7brNqULkCU/8= X-Received: by 2002:a17:903:3845:b0:2b0:6a22:5165 with SMTP id d9443c01a7336-2b9d37cca38mr586775ad.7.1777581685389; Thu, 30 Apr 2026 13:41:25 -0700 (PDT) MIME-Version: 1.0 References: <080f9394-c127-4cef-865e-10f2f997125c@postgrespro.ru> <38690b0e-f91b-46fa-b72a-57775612e463@postgrespro.ru> In-Reply-To: From: Masahiko Sawada Date: Thu, 30 Apr 2026 13:40:47 -0700 X-Gm-Features: AVHnY4LzjX-9pcPwGbzWjrsZB6cPyfVlKXGpdF296R5Hz5RL7B6neXnhxyHBR4E Message-ID: Subject: Re: Support logical replication of DDLs, take2 To: Amit Kapila Cc: Vitaly Davydov , Ashutosh Bapat , 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 Wed, Apr 29, 2026 at 9:44=E2=80=AFPM Amit Kapila wrote: > > On Wed, Apr 29, 2026 at 3:19=E2=80=AFAM Masahiko Sawada wrote: > > > > On Mon, Apr 27, 2026 at 11:32=E2=80=AFPM Amit Kapila wrote: > > > > > > Yes, there will be a maintenance cost of JSON-based deparsing > > > approach. But note that multiple senior people (Alvaro Herrera, Rober= t > > > Haas) [1] seems to favor that approach. So, I am not sure we can > > > conclude to abandon that approach without those people or some other > > > senior people agreeing to abandon it. To be clear, I am not against > > > considering a new/different approach for DDL replication but just tha= t > > > it is not clear that old/existing approach can be ruled out without > > > more discussion on it, > > > > Thank you for pointing it out. Just to be clear, IIUC what they liked > > was to use JSON string representation of DDLs, but not JSON string > > representation of DDLs that are deparsed from parse nodes, no? > > > > As per my understanding, we built deparsing stuff with a goal of > supporting DDL replication and Alvaro was the original author of that > work, see [1]. The benefit it provides flexibility in terms of > filtering by decoding plugin, if any, or changing the DDL (like > schema-mapping) during apply. It is not clear to me if we can achive > similar level of flexibility with other approach. I think we can generate the same JSON-string representation of DDLs from catalog information, it would also require a lot of code, though. It would be independent from parse nodes and if we implement it as an option for pg_get_xxx_ddl() functionality it would be able to be reused by other tools too. > > > > > > > > > We would need to maintain the JSON serialization code whenever > > > > creating or modifying parse nodes, regardless of whether the change= s > > > > were related to DDL replication. IIUC, this was the primary reason = the > > > > feature didn't cross the finish line. > > > > > > > > Additionally, I think there is another design issue: it is not > > > > output-plugin agnostic. Since the deparsed DDL was written by a > > > > logical-replication-specific event trigger, third-party logical > > > > decoding plugins cannot easily detect DDL events. > > > > > > > > > > Why RmgrId like RM_LOGICALDDLMSG_ID and XLOG_LOGICAL_DDL_MESSAGE wal > > > info is not sufficient for this? Decoder will add a message like > > > REORDER_BUFFER_CHANGE_DDL which can be used to detect DDL message, no= ? > > > > Right, but I'm not sure this is a good developer experience that > > additional steps are required to capture DDL events for other plugins > > while changes of INSERT/UPDATE/DELETE/TRUNCATE are passed from the > > logical decoding by default. > > > > Yes, there could probably be additional steps for plugins but they > must be doing a few things already which are defined at publication > level like column lists, row filtering, something related to RI, etc. I think those publication-level features operate at a somewhat different layer than the fundamental mechanism of capturing DDL events. Plugins filter rows or columns based on configuration, but the logical decoding itself guarantees that the DML events are reliably passed to them. Given that the TRUNCATE in logical replication already works so, I guess DDL should have the same fundamental guarantee. it's unclear to me how plugins could reliably manage these event triggers. While a plugin might create an event trigger during the startup callback if it doesn't exist, it cannot drop it during the shutdown callback. We also cannot establish a dependency between an event trigger and a logical replication slot. We would likely need to invent a new plugin callback specifically invoked at slot drop time just to clean it up. Also, if different plugins want to capture DDL events, they could end up registering different event triggers, emitting multiple DDL WAL records for the same DDL event. > To reduce the plugin work, one naive idea is to let the event triggers > be registered at first logical slot creation or may be at init time of > plugin. I think we need to note that replication slot creation and drop are non-transactional operations. We need to make sure that both logical slots and the event trigger are not orphaned in error or server crash cases. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com