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 1phorJ-0005od-K7 for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Mar 2023 09:46:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1phorI-0008RG-HE for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Mar 2023 09:46:16 +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 1phorI-0008R7-4e for pgsql-hackers@lists.postgresql.org; Thu, 30 Mar 2023 09:46:16 +0000 Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1phorF-0007qM-1H for pgsql-hackers@lists.postgresql.org; Thu, 30 Mar 2023 09:46:15 +0000 Received: by mail-oi1-x22e.google.com with SMTP id be10so397704oib.6 for ; Thu, 30 Mar 2023 02:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680169571; x=1682761571; 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=IW+izruFBEqObQEhLWE9QSd2jICo1HuRDD3pXCpEZNA=; b=Agcwg39uuFxnMRmQ2LH5ShxbTow5zQdDXzIQUz3XK8uUzV8nX0DykzxX7tMG8G64cM sezJVp0JMQRfDpGXABD3bydGYJzIXZwzT7gk+jQQpG6BgthFlCfM0EFHZLNAqSonOWCB obq/57VmXLrFeKKabYYi/S3AEv1tfbTNYMwcac06fkEVRHiBH5I6qjIHe4AwdJtrRCEi HHKEKMjTl0jzwffvI7SG+SXCNsk6RcWp250RL/+BI8Ty31SIlbrrEuEpveEnM5M98xN7 JAULrPqwm9Z5hPjW9NglyNLwXBBlWED1AWQhlTZruLz7vblpZ8G25R9xUWwGqajQKM1l lLGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680169571; x=1682761571; h=content-transfer-encoding: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=IW+izruFBEqObQEhLWE9QSd2jICo1HuRDD3pXCpEZNA=; b=wP/6yWGb9olzWYCXkl5NffAnCj5zP78OJKowPMHSDrbTJy5uV6htn53dZ4nP0bpWxL md7ILEm8fimDQNXjxLH1nx3QrI/MWHtvHf+8ev5M2T2WYZIcoVxDzCa6LF2JNx96Rh0z yRsTmUrm2v9bVSdmhbt5xdszp/iSq2vG/uP6afuzlF4RDKslt9LY8Fl7+1SQUM1XVEED PSjLd/2kFsaP2QbeP44R30IquqiK80Rk7UjmLIJy2Zfppi8VeVi70YummAuwIOGU38h3 qQ022dhjTZrgdm2tPUaO/zumSoxnrNYM7iYKAhR0krngetkYXf3aSendqgRz5A/drjWo 22wg== X-Gm-Message-State: AO0yUKVcJx+FV9Nbh4uKbPuAnDD5TX13fkHwiGTUzOrCA/iDgHhF2WeL AmhjnjKT5u3Zl9yTTbB5czvDyy/BRuGBHFOx6IE= X-Google-Smtp-Source: AK7set/X4mj4YdTe14EguT5H3PqIpYI7JGmZk+Y0TCrUgDnf6ai75OWZfFEm2GFnElOTWPI0TkeuTBlZse4Jm08kAEk= X-Received: by 2002:a05:6808:b22:b0:384:2150:4f6 with SMTP id t2-20020a0568080b2200b00384215004f6mr6549367oij.7.1680169571006; Thu, 30 Mar 2023 02:46:11 -0700 (PDT) MIME-Version: 1.0 References: <3032112.1679865718@sss.pgh.pa.us> In-Reply-To: From: vignesh C Date: Thu, 30 Mar 2023 15:15:59 +0530 Message-ID: Subject: Re: Support logical replication of DDLs To: "houzj.fnst@fujitsu.com" Cc: Amit Kapila , Ajin Cherian , "wangw.fnst@fujitsu.com" , Runqi Tian , Peter Smith , Tom Lane , li jie , Dilip Kumar , Alvaro Herrera , Masahiko Sawada , Japin Li , rajesh singarapu , PostgreSQL Hackers , Zheng Li 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 Thu, 30 Mar 2023 at 13:29, houzj.fnst@fujitsu.com wrote: > > > > > -----Original Message----- > > From: houzj.fnst@fujitsu.com > > Sent: Thursday, March 30, 2023 2:37 PM > > > > On Tuesday, March 28, 2023 12:13 PM houzj.fnst@fujitsu.com > > wrote: > > > > > > On Monday, March 27, 2023 8:08 PM Amit Kapila > > > > > wrote: > > > > On Mon, Mar 27, 2023 at 12:07=E2=80=AFPM Amit Kapila > > > > wrote: > > > > > > > > > > On Mon, Mar 27, 2023 at 2:52=E2=80=AFAM Tom Lane wrote: > > > > > > > > > > > > > > > > > I suggest taking a couple of steps back from the minutiae of th= e > > > > > > patch, and spending some hard effort thinking about how the thi= ng > > > > > > would be controlled in a useful fashion (that is, a real design > > > > > > for the filtering that was mentioned at the very outset), and > > > > > > about the security issues, and about how we could get to a > > committable > > > patch. > > > > > > > > > > > > > > > > Agreed. I'll try to summarize the discussion we have till now on > > > > > this and share my thoughts on the same in a separate email. > > > > > > > > > > > > > The idea to control what could be replicated is to introduce a new > > > > publication option 'ddl' along with current options 'publish' and > > > > 'publish_via_partition_root'. The values of this new option could b= e > > > > 'table', 'function', 'all', etc. Here 'all' enables the replication= of > > > > all supported DDL commands. Example usage for this would be: > > > > Example: > > > > Create a new publication with all ddl replication enabled: > > > > CREATE PUBLICATION pub1 FOR ALL TABLES with (ddl =3D 'all'); > > > > > > > > Enable table ddl replication for an existing Publication: > > > > ALTER PUBLICATION pub2 SET (ddl =3D 'table'); > > > > > > > > This is what seems to have been discussed but I think we can even > > > > extend it to support based on operations/commands, say one would li= ke > > > > to publish only 'create' and 'drop' of tables. Then we can extend t= he > > > > existing publish option to have values like 'create', 'alter', and = 'drop'. > > > > > > > > Another thing we are considering related to this is at what level > > > > these additional options should be specified. We have three variant= s > > > > FOR TABLE, FOR ALL TABLES, and FOR TABLES IN SCHEMA that enables > > > > replication. Now, for the sake of simplicity, this new option is > > > > discussed to be provided only with FOR ALL TABLES variant but I thi= nk > > > > we can provide it with other variants with some additional > > > > restrictions like with FOR TABLE, we can only specify 'alter' and > > > > 'drop' for publish option. Now, though possible, it brings addition= al > > > > complexity to support it with variants other than FOR ALL TABLES > > > > because then we need to ensure additional filtering and possible > > > > modification of the content we have to send to downstream. So, we c= an > > even > > > decide to first support it only FOR ALL TABLES variant. > > > > > > > > The other point to consider for publish option 'ddl =3D table' is > > > > whether we need to allow replicating dependent objects like say som= e > > > > user-defined type is used in the table. I guess the difficulty here > > > > would be to identify which dependents we want to allow. > > > > > > > > I think in the first version we should allow to replicate only some= of > > > > the objects instead of everything. For example, can we consider onl= y > > > > allowing tables and indexes in the first version? Then extend it in= a phased > > > manner? > > > > > > I think supporting table related stuff in the first version makes sen= se and the > > > patch size could be reduced to a suitable size. > > > > Based on the discussion, I split the patch into four parts: Table DDL > > replication(0001,0002), Index DDL replication(0003), ownership stuff fo= r table > > and index(0004), other DDL's replication(0005). > > > > In this version, I mainly tried to split the patch set, and there are f= ew > > OPEN items we need to address later: > > > > 1) The current publication "ddl" option only have two values: table, al= l. We > > also need to add index and maybe other objects in the list. > > > > 2) Need to improve the syntax stuff. Currently, we store the option val= ue of > > the "with (ddl =3D xx)" via different columns in the catalog, the > > catalog(pg_publication) will have more and more columns as we add > > support > > for logical replication of other objects in the future. We could sto= re it as > > an text array instead. > > > > OTOH, since we have proposed some other more flexible syntax to -hac= kers, > > the current > > syntax might be changed which might also solve this problem. > > > > 3) The test_ddl_deparse_regress test module is not included in the set, > > because > > I think we also need to split it into table stuff, index stuff and o= thers, > > we can share it after finishing that. > > > > 4) The patch set could be spitted further to make it easier for reviewe= r like: > > infrastructure for deparser, deparser, logical-decoding, built-in lo= gical > > replication, We can do it after some analysis. > > > > [1] > > https://www.postgresql.org/message-id/OS0PR01MB571646874A3E165D939 > > 99A9D94889%40OS0PR01MB5716.jpnprd01.prod.outlook.com > > The patch needs a rebase due to a recent commit da324d6, here is the reba= sed version. Thanks for the patches, Few comments: 1: create unlogged is replicated but the insert on the same is not replicat= ed: create unlogged table t3(c1 int); -- The insert on this is not replicated 2: "Using index tablespace" option is not replicated: create table t3 (c1 int unique using index tablespace tbs1); publisher: \d+ t3 Table "public.t3" Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description --------+---------+-----------+----------+---------+---------+-------------= +--------------+------------- c1 | integer | | | | plain | | | Indexes: "t3_c1_key" UNIQUE CONSTRAINT, btree (c1), tablespace "tbs1" Publications: "pub1" Access method: heap Subscriber: \d+ t3 Table "public.t3" Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description --------+---------+-----------+----------+---------+---------+-------------= +--------------+------------- c1 | integer | | | | plain | | | Indexes: "t3_c1_key" UNIQUE CONSTRAINT, btree (c1) Access method: heap 3:The create table is not replicated whereas the drop table of the same is replicated with PUBLISH_VIA_PARTITION_ROOT as default (false): create table t1(c1 int) partition by hash ( c1); drop table t1; 4: Should we document tablespace creation should be taken care of by user: create table t1(c1 int) tablespace tbs1; -- As tablespace tbs1 does not exist in the subscriber, should we add some documentation for this. 5: temporary table is not replicated, should we add some documentation for = this: create global temporary table t2(c1 int); -- Should we add some documentation for this Regards, Vignesh