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.94.2) (envelope-from ) id 1ue8rv-005XuD-NX for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Jul 2025 09:01:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ue8qw-0062Ja-Oq for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Jul 2025 09:00:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ue8qw-0062Iz-Dq for pgsql-hackers@lists.postgresql.org; Tue, 22 Jul 2025 09:00:02 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ue8qt-000CEz-2A for pgsql-hackers@lists.postgresql.org; Tue, 22 Jul 2025 09:00:02 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-234f17910d8so46398765ad.3 for ; Tue, 22 Jul 2025 02:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753174799; x=1753779599; 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=tiJ9M8OYBHFtrd+J5pNFgJnScVuQF82Y5gXrxUcn7Wc=; b=V3awIEzju8L94y29fII2M9sDyKm5xa/nMgVrR2DzMZwcawulGGtvxSQTQ+ra83TEzb 3kK+3ddnJopNfhGnmdeTCGNov/Q7wyJXcTWh2fZsp5AkFevYBjphntpA8u5y5ivGi+fZ OpnvvMfdKYZN7OX6MTVPuVYCBtPjjFh+7hpgg1frykxQMcCxY4ogDa47NDSQixEA08/9 M5vT6KVlxWh8ZG/wj5dUgEmdQGkPSbOfqFRuiK/9owG7lWsyi3hjOeU4wzx+uud5ulJ0 94l5hf5TvwCsX4PwhOOOvXkRZZ/b4FQtUf64oOFsZV+tnkvxfiGJu2zXXjqMymBnLVWm Twcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753174799; x=1753779599; 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=tiJ9M8OYBHFtrd+J5pNFgJnScVuQF82Y5gXrxUcn7Wc=; b=hjnG57xoq/0q4jZ3Lq6Mv/uBRpAqPo3vYDKfdmpzYs1xShjIssAX8rAFQy9E7deL2A i+ZcjzTPm+t9PVZGG0SuH83H91D/77GX77iWsAO3UKMllnDNBOg3WQQOBoRLtmYtvncl A9vondi+HmPPPh10tpdoPKURBm1lm69dXJJbH22Kyb9oYYCNtURUeB+9lMS/j43YF4W1 73MJTBsmhWGR6CfOP8tbLzq6zlCE2nZ+CwyuioPhFTsFcKy8SllpU+a/mwakq4Ex383W qyrkwP7YSuRTYuK+92EcazWp5PG/SPIsYPV00QphF+JYLkIG3u6H2Pcks3X+1td7oSky VtRA== X-Forwarded-Encrypted: i=1; AJvYcCWTsdO/E/1BX5i2puC1ENYsVrXFH+IX+rZRu3OSzX2CeDfh2PVhawnGMi+rLh5Jrg0D/dNCnFDo4L2hV5+a@lists.postgresql.org X-Gm-Message-State: AOJu0YysF/YgbaMr5sZJsbdNyMo+J8X+TfLkSa41uBXVdUKHrqfUKY2u i00WjG5/+r0XyhOE8a/Ij0qwEtB4xwIgwJ10WupRzJ0JXcblKLXPZ3B1yi7SGDRrmv7s0zdPG2d RqFc0Rfh/aF813getODuJP4w0i65WuwE= X-Gm-Gg: ASbGncsdoXmKZLlozGKkGDAaYnTq4jjKIRqwmXLNT1pvy0f75KrxgRuvel58CUH3FbB puJ6c8nLu7EkTH7df2A3LJpd/q6Ncxq46qLZUH/6FLUCgCyWNc9VA4GszjDbS8/ZjpwWK1dNM3P exb8CtnkcRbAvT7EL+y5cOimrR8sr+0FRZqGyHs7gMsqzCVIJTRoFc15LwS7g64MnkeXpeP2G4h m3MnVjkP+KcaLBLKOZB X-Google-Smtp-Source: AGHT+IGP3KcHsBBYrvnBI4c5WTe4xtJW3Acu8tUvTeDaodA4nIYr1qx6tAMRZntUazZ6DfWkzyolgtYlAezkmxMLe/I= X-Received: by 2002:a17:903:1105:b0:234:8a4a:adb4 with SMTP id d9443c01a7336-23e3b79a73emr198096535ad.21.1753174798652; Tue, 22 Jul 2025 01:59:58 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: shveta malik Date: Tue, 22 Jul 2025 14:29:45 +0530 X-Gm-Features: Ac12FXxRy3ddUBS9pJIS4Fra11t9r3OL2yzABhkRRBg69Q-oOzSSDb3nS00I8zI Message-ID: Subject: Re: Skipping schema changes in publication To: Shlok Kyal Cc: Peter Smith , Amit Kapila , "Zhijie Hou (Fujitsu)" , vignesh C , YeXiu <1518981153@qq.com>, Ian Lawrence Barwick , Bharath Rupireddy , PostgreSQL Hackers , shveta malik 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 Sat, Jul 19, 2025 at 4:17=E2=80=AFPM Shlok Kyal wrote: > > On Mon, 30 Jun 2025 at 16:25, shveta malik wrote= : > > > > Few more comments on 002: > > > > 5) > > +GetAllTablesPublicationRelations(Oid pubid, bool pubviaroot) > > { > > > > + List *exceptlist; > > + > > + exceptlist =3D GetPublicationRelations(pubid, PUBLICATION_PART_ALL); > > > > > > a) Here, we are assuming that the list provided by > > GetPublicationRelations() will be except-tables list only, but there > > is no validation of that. > > b) We are using GetPublicationRelations() to get the relations which > > are excluded from the publication. The name of function and comments > > atop function are not in alignment with this usage. > > > > Suggestion: > > We can have a new GetPublicationExcludeRelations() function for the > > concerned usage. The existing logic of GetPublicationRelations() can > > be shifted to a new internal-logic function which will accept a > > 'except-flag' as well. Both GetPublicationRelations() and > > GetPublicationExcludeRelations() can call that new function by passing > > 'except-flag' as false and true respectively. The new internal > > function will validate 'prexcept' against that except-flag passed and > > will return the results. > > > I have made the above change. Thank You for the changes. 1) But on rethinking, shall we make GetPublicationRelations() similar to : /* Gets list of publication oids for a relation that matches the except_fla= g */ GetRelationPublications(Oid relid, bool except_flag) i.e. we can have a single function GetPublicationRelations() taking except_flag and comment can say: 'Gets list of relation oids for a publication that matches the except_flag.' We can get rid of GetPubIncludedOrExcludedRels() and GetPublicationExcludeRelations(). Thoughts? 2) we can rename except_table to except_flag to be consistent with GetRelationPublications() 3) + if ((except_table && pubrel->prexcept) || !except_table) + result =3D GetPubPartitionOptionRelations(result, pub_partopt, + pubrel->prrelid); 3a) In the case of '!except_table', we are not matching it with 'pubrel->prexcept', is that intentional? 3 b) Shall we simplify this similar to the changes in GetRelationPublications() = i.e. if (except_table/flag =3D=3D pubrel->prexcept) result =3D GetPubPartitionOptionRelations(...) > > > 6) > > Before your patch002, GetTopMostAncestorInPublication() was checking > > pg_publication_rel and pg_publication_namespace to find out if the > > table in the ancestor-list is part of a given particular. Both > > pg_publication_rel and pg_publication_namespace did not have the entry > > "for all tables" publications. That means > > GetTopMostAncestorInPublication() was originally not checking whether > > the given puboid is an "for all tables" publication to see if a rel > > belongs to that particular pub or not. I > > > > But now with the current change, we do check if pub is all-tables pub, > > if so, return relid and mark ancestor_level (provided table is not > > part of the except list). IIUC, the result in 2 cases may be > > different. Is that the intention? Let me know if my understanding is > > wrong. > > > This is intentional, in function get_rel_sync_entry, we are setting > pub_relid to the topmost published ancestor. In HEAD we are directly > setting using: > /* > * If this is a FOR ALL TABLES publication, pick the partitio= n > * root and set the ancestor level accordingly. > */ > if (pub->alltables) > { > publish =3D true; > if (pub->pubviaroot && am_partition) > { > List *ancestors =3D get_partition_ancestors(rel= id); > > pub_relid =3D llast_oid(ancestors); > ancestor_level =3D list_length(ancestors); > } > } > In HEAD, we can directly use 'llast_oid(ancestors)' to get the topmost > ancestor for case of FOR ALL TABLES. > But with this proposal. This change will no longer be valid as the > 'llast_oid(ancestors)' may be excluded in the publication. So, to > handle this change was made in GetTopMostAncestorInPublication. > > > Also, during testing with the partitioned table and > publish_via_partition_root the behaviour of the current patch is as > below: > For example we have a partitioned table t1. It has partitions part1 > and part2. Now consider the following cases: > 1. with publish_via_partition_root =3D true > I. If we create publication on all tables with EXCEPT t1, no data > for t1, part1 or part2 is replicated. Okay. Agreed. > II. If we create publication on all tables with EXCEPT part1, > data for all tables t1, part1 and part2 is replicated. Okay. Is this because part1 changes are replicated through t1 and since t1 changes are not restricted, part1 changes will also not be restricted? In other words, part1 was never published directly in the first place and thus 'EXCEPT part1' has no meaning when 'publish_via_partition_root' =3D true? IMO, it is in alignment with the 'publish_via_partition_root' definition but it might not be that intuitive for users. So shall we emit a WARNING: WARNING: Partition "part1" is excluded, but publish_via_partition_root =3D true, so this will have no effect. Thoughts? > 2. with publish_via_partition_root =3D false > I. If we create publication on all tables with EXCEPT t1, no data > for t1, part1 or part2 is replicated. I think we shall still publish partitions here. Since publish_via_partition_root is false, part1 and part2 are published individually and thus shall we allow publishing of part1 and part 2 here? Thoughts? > II. If we create publication on all tables with EXCEPT part1, > data for part1 is not replicated > Agreed. thanks Shveta