From: | Peter Smith <smithpb2250(at)gmail(dot)com> |
---|---|
To: | Shubham Khanna <khannashubham1197(at)gmail(dot)com> |
Cc: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Add support for specifying tables in pg_createsubscriber. |
Date: | 2025-10-01 00:30:05 |
Message-ID: | CAHut+PvpZcCwjJxjQNt3nPFCrmFg-2EzfGWNOOG=dB8BeNziGw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Shubham,
Here are some v13 review comments.
======
src/bin/pg_basebackup/pg_createsubscriber.c
1.
- /*
- * In dry-run mode, we don't create publications, but we still try to drop
- * those to provide necessary information to the user.
- */
if (!drop_all_pubs || dry_run)
- drop_publication(conn, dbinfo->pubname, dbinfo->dbname,
- &dbinfo->made_publication);
+ {
+ /*
+ * Since the publications were created before the consistent LSN, they
+ * remain on the subscriber even after the physical replica is
+ * promoted. Only drop publications that were created by
+ * pg_createsubscriber during this operation. Pre-existing
+ * publications are preserved.
+ */
+ if (!drop_all_pubs && dbinfo->made_publication)
+ drop_publication(conn, dbinfo->pubname, dbinfo->dbname,
+ &dbinfo->made_publication);
+ else if (!drop_all_pubs)
+ pg_log_info("preserve existing publication \"%s\" in database \"%s\"",
+ dbinfo->pubname, dbinfo->dbname);
+ }
1a.
Sorry, that code looks wrong to me. Notice, the result of that patch
fragment is essentially:
if (!drop_all_pubs || dry_run)
{
if (!drop_all_pubs && dbinfo->made_publication)
drop_publication(...);
else if (!drop_all_pubs)
pg_log_info("preserve existing...";
}
You've coded *every* condition say !drop_all_pubs, which is basically
saying when drop_all_pubs == true then dry_run does nothing at all
(??). Surely, that's not the intention.
Let's see a specific test case: --publication=mynew
--clean=publications --dry-run
According to your matrix, AFAICT, you expect this to log:
- "create publication mynew"
- "dropping all existing"
- "dropping other existing..." (loop)
- "drop publication mynew"
But, I don't see how that "drop publication mynew" is possible with
this code. Can you provide some test/script output as proof that it
actually works like you say it does?
~~~
1b.
The original code at least had a comment saying what it was trying to do:
- /*
- * In dry-run mode, we don't create publications, but we still try to drop
- * those to provide necessary information to the user.
- */
Why was that comment removed? In my v12 review, I suggested some
possible better wording [1] for that. Please imagine someone reading
this code without handy access to that "expected logging" matrix, and
write explanatory comments accordingly.
Kind Regards,
Peter Smith.
Fujitsu Australia.
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Smith | 2025-10-01 02:29:56 | pg_createsubscriber --dry-run logging concerns |
Previous Message | David Rowley | 2025-10-01 00:07:10 | Re: [PATCH] Add tests for Bitmapset |