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 1pFKQ9-0004P8-0a for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Jan 2023 19:36:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pFKQ7-00069M-P2 for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Jan 2023 19:36:27 +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 1pFKQ7-00068t-Dv for pgsql-hackers@lists.postgresql.org; Tue, 10 Jan 2023 19:36:27 +0000 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pFKQ5-0002dT-4R for pgsql-hackers@lists.postgresql.org; Tue, 10 Jan 2023 19:36:27 +0000 Received: by mail-oi1-x22c.google.com with SMTP id s66so10336281oib.7 for ; Tue, 10 Jan 2023 11:36:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timescale.com; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=u5e/8xD9sc4W4+/o3a4nqChiW2yB2WoAUvsMFqeg3BU=; b=QGlJFx7tFM4zcv/OlNFGrpaNhGcHLd7plJXBsMd5dIL+YuHQDuGPYHadMY/lNTc/YZ GXBqwRbjL1kQLs6/+KE562Bxg+UsG3NPv3d28LhhOF8bAco8noMEJnnq5Ik8hs6CsS96 jCsY5lycNdDmvrbBi6cpiV9Nv/U6F4Ic0yTbFwV8ARPxm94Nw3+zaRulO294CZ5di45b +8c48dbj5xqRf02l+Xbhnxp3he0ya2a/Ca1qNh387o2uCJmZWNmmMDXyTk8tyLczO/w/ q0yGqnnqKbED2z+8TvaIEKvc5D+dYHymH13Dycdo9TusHSF7AQSfy9OBHs9yNM7M65b6 pVzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u5e/8xD9sc4W4+/o3a4nqChiW2yB2WoAUvsMFqeg3BU=; b=YsF6/VDbgBDOpIfuTJScoyvn6kY9Glb63F4DKqoCECnhm+fxDP5iqbOhC+XfTyY7Cv x/BgiNKsz2LKT+sXKy1hAPtKtqDz2mEuwyitsLFlyxKrnjRQdbcPpeD8Mh6DlkxkP6cS U2YsQ3CIAqlSdpDcXXlkSmjwdF3f0AbCwtabsCD35bzW7w6LYR34gQIE1CDZDrqW+GoO VvAW6qBWKZnl0Qk7rfqGRksVWfLRJ+kqY7OshO9mIr9mAXuDesGcKUrAo8pnatg95sTD ItgC5AYbsfpTblJ9mI2CkN7gEmrIQgzMBHPkTONegKN2N2BOyBqDbTik4ekXNL33Z2Ef 0VQA== X-Gm-Message-State: AFqh2krqocbWwpzWTTuXt8bFxZ6B2cKKl4STVAR/aGJhK9ZHzigXxa2h vSoqm75P2T8erPu5NEluqCA4r2yvAe9qQLe9vc7xfEnBHCmhxx08 X-Google-Smtp-Source: AMrXdXtqSRoRtkeEr5ygx7Zb+Jy/XaI5yzzkhmC9dgUz0fmf3BOLoqyTzerHlAVw3RJnrikSfRK4Hgp+1pP18NzLfAM= X-Received: by 2002:aca:a808:0:b0:364:59a6:a48a with SMTP id r8-20020acaa808000000b0036459a6a48amr273751oie.117.1673379383411; Tue, 10 Jan 2023 11:36:23 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jacob Champion Date: Tue, 10 Jan 2023 11:36:12 -0800 Message-ID: Subject: Re: RFC: logical publication via inheritance root? To: Aleksander Alekseev Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jan 9, 2023 at 12:41 AM Aleksander Alekseev wrote: > I would like to point out that we shouldn't necessarily support > multiple inheritance in all the possible cases, at least not in the > first implementation. Supporting simple cases of inheritance would be > already a valuable feature even if it will have certain limitations. I agree. What I'm trying to avoid is the case where replication works nicely for a table until someone performs an ALTER TABLE ... [NO] INHERIT, and then Something Bad happens because we can't support the new edge case. If every inheritance tree is automatically opted into this new publication behavior, I think it'll be easier to hit that by accident, making the whole thing feel brittle. By contrast, if we have to opt specific tables into this feature by marking them in the catalog, then not only will it be harder to hit by accident (because we can document the requirements for the marker function, and then it's up to the callers/extension authors/DBAs to maintain those requirements), but we even have the chance to bail out during an inheritance change if we see that the table is marked in this way. Two general pieces of progress to report: 1) I'm playing around with a marker in pg_inherits, where the inhseqno is set to a sentinel value (0) for an inheritance relationship that has been marked for logical publication. The intent is that the pg_inherits helpers will prevent further inheritance relationships when they see that marker, and reusing inhseqno means we can make use of the existing index to do the lookups. An example: =# CREATE TABLE root (a int); =# CREATE TABLE root_p1 () INHERITS (root); =# SELECT pg_set_logical_root('root_p1', 'root'); and then any data written to root_p1 gets replicated via root instead, if publish_via_partition_root = true. If root_p1 is set up with extra columns, they'll be omitted from replication. 2) While this strategy works well for ongoing replication, it's not enough to get the initial synchronization correct. The subscriber still does a COPY of the root table directly, missing out on all the logical descendant data. The publisher will have to tell the subscriber about the relationship somehow, and older subscriber versions won't understand how to use that (similar to how old subscribers can't correctly handle row filters). --Jacob