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 1udwIo-002fMD-8a for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jul 2025 19:35:59 +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 1udwIn-002b1C-Bx for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jul 2025 19:35:57 +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 1udwIn-002b12-1V for pgsql-hackers@lists.postgresql.org; Mon, 21 Jul 2025 19:35:57 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1udwIj-0005pw-1m for pgsql-hackers@lists.postgresql.org; Mon, 21 Jul 2025 19:35:56 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-73e810dc22dso2004532a34.3 for ; Mon, 21 Jul 2025 12:35:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753126552; x=1753731352; 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=Dj+DyEg8C39ZpoHksx11G9JJchlSRlV+BCyQ0xPpwfw=; b=cWYhI1TNh1k7pHc8QfcXF4ozOvVH/TEFREsxtpZwOigf8cpXiN+Lnh7H1HL6219KWl rgeubomZSc6FaSskXr5BCG5khm4jKYHC2wtEf361Ou7Oz5BHL/Avhj0Tj+0zYnruMhy9 hCulJdW3qhaGA9w2sFbwKlrXZ7o0jE8OeMlb9uwMpGfeg9kxq7MfL0PWIl0E6vb2kD/S WEB1FyYxMGXwsLJnGf/zWWWCtCfxvCkBkLL1Aq8SSeK788jaqoYBJ3b0NfTMAfFRmv0H +6IOecv0GKmjPchzeNg76uWM6akkNBB7sFT+7q4fFbiDGeyqINF1Gu+RDB6ZJC75ul1r 6dVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753126552; x=1753731352; 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=Dj+DyEg8C39ZpoHksx11G9JJchlSRlV+BCyQ0xPpwfw=; b=Qh5QDhsw0XBx+ih58PtA/T6kbISzfz6nAMnZfHykMIwvX7A1t+UCMO6VfrYAwj6KJR SyFW0ZLODozLp7I4385OHUqk0okSuQ8dBwDId+u+fNt8GyQuQHdHgaCOwde7n0goSIRx 1FKB6+SRvt//qK7zKpCtefXPuysXgGGtjktei3CsEB49Y2Ao9fcXJkepDS2IuVz9vKpn FsdIXQrU0LOax8jSfS8dN/JS4qOgxMMW/clIqB+W/nVDQWpq73qZCzE2lclQLKScQq2W i+Ayjd5yYIHKnXNdTYYFReAQQlHKYr68Wp6SUgy7pn8xKcFlQmbaW225TzX/vCrN2f5d //CQ== X-Forwarded-Encrypted: i=1; AJvYcCWISefutRZyFepk6+huH+gfsfTEBiHFzbFK8CNt0l7ICq+oLFHo1JIl8Ped6TFyxpBe8evMvyd/YeObhcJy@lists.postgresql.org X-Gm-Message-State: AOJu0YwNqqBGOH7VNszjprO8QabKtZBH+5Sk5aHaVYvBlMUzLmWJVad2 3LGqpUjk2SEor0Sdrvu6MwZ+Pq4/Z/Vh8Z8lgYY8UXHVGNCGywF72szk7Zr3x+/T9YzVztfRRTi BhHLL9SM+EhdCyE/3QFFxcqKhQjTb4Cw= X-Gm-Gg: ASbGncuX+lzcCmLrHjodX2LThA+dAHfUTkyxDIhDuZDlyrpfbU54HoEJqkA5dYt6Mrb cWEbHypAQFR1JUHsPpQVvXiTJOTiUvfEgL2n/Rux5oIgDUou19+qV7eQjfT/WksEdIW7pOc9rld ifQxMV58rFP/h//qiDNH/wfjbxEDGSneZZ0IYZXMstLxPTs5xXM2Wx9MBs4WikAg+vpGl/W7/bA UEQ4EVNFQ== X-Google-Smtp-Source: AGHT+IFLbK4kvQzwudXstMjNmiYa1a2u322UWcs6CzRVdK4TyC9qeT+ZH+KV2k4g2hYyQ/6BLpangr4HaneffI6tVxg= X-Received: by 2002:a05:6808:818b:b0:424:b42a:6e6c with SMTP id 5614622812f47-424b42a745emr475252b6e.32.1753126552180; Mon, 21 Jul 2025 12:35:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shlok Kyal Date: Tue, 22 Jul 2025 01:05:40 +0530 X-Gm-Features: Ac12FXyR9eTW_X_dk7SCEHJcbA1nCy7-PwGn2jlgwXwMP3SWoFxZH3MF-o8JgdI Message-ID: Subject: Re: Skipping schema changes in publication To: shveta malik Cc: Peter Smith , Amit Kapila , "Zhijie Hou (Fujitsu)" , vignesh C , YeXiu <1518981153@qq.com>, Ian Lawrence Barwick , Bharath Rupireddy , 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 Mon, 21 Jul 2025 at 16:22, shveta malik wrote: > > On Sat, Jul 19, 2025 at 4:17=E2=80=AFPM Shlok Kyal wrote: > > > > On Mon, 30 Jun 2025 at 16:25, shveta malik wro= te: > > > > > > 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 passin= g > > > '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. > > > > > > > 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 entr= y > > > "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 partit= ion > > * root and set the ancestor level accordingly. > > */ > > if (pub->alltables) > > { > > publish =3D true; > > if (pub->pubviaroot && am_partition) > > { > > List *ancestors =3D get_partition_ancestors(r= elid); > > > > 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. > > II. If we create publication on all tables with EXCEPT part1, > > data for all tables t1, part1 and part2 is replicated. > > 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. > > II. If we create publication on all tables with EXCEPT part1, > > data for part1 is not replicated > > > > Is this behaviour fine? > > I checked for other databases such as MySQL, SQL Server. In that we do > > not have such cases as either we replicate the whole partitioned table > > or we not replicated at all. We do not have partition level control. > > For Oracle, I found that we can include or exclude partitions using > > 'PARTITIONEXCLUDE' [2], but did not find something similar to > > publish_via_partition_root or where partitions are published as > > separate tables. > > What are your thoughts on the above behaviour? > > > > Thank You for the details. I will review this behaviour soon and will > let you know my comments. Meanwhile, please find a few comments on > v16-0001: > > 1) > we do LockSchemaList() everywhere before we call > PublicationDropSchemas() to prevent concurrent schema deletion. Do we > need that in reset flow as well? Added > > 2) > + /* Drop the schemas associated with the publication */ > + schemas =3D GetPublicationSchemas(pubid); > + PublicationDropSchemas(pubid, schemas, true); > + > + /* Get all relations associated with the publication */ > + relids =3D GetPublicationRelations(pubid, PUBLICATION_PART_ROOT); > > We can rename schemas to schemaids similar to relids, as > GetPublicationSchemas return oids. > Fixed > 3) > + /* Drop the relations associated with the publication */ > + PublicationDropTables(pubform->oid, rels, true); > > we can pass 'pubid' here instead of pubform->oid > Modified > 4) > Shall we modify the comments: > 'Drop the relations associated with the publication' to 'Remove the > associated relations from the publication' > 'Drop the schemas associated with the publication' to 'Remove the > associated schemas from the publication' > > Similar changes can be done in test file's comments as well > --Verify that tables associated with the publication are dropped after > RESET > --Verify that schemas associated with the publication are dropped after R= ESET > Fixed I have made the changes in the latest v17 patch [1]. [1]: https://www.postgresql.org/message-id/CANhcyEUtYV-9ujtxLasnxN_peT%2B3L= uZjcRx1xUECh1CCmANB8w%40mail.gmail.com Thanks, Shlok Kyal