From: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
---|---|
To: | 'Shubham Khanna' <khannashubham1197(at)gmail(dot)com> |
Cc: | Euler Taveira <euler(at)eulerto(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, Ajin Cherian <itsajin(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
Subject: | RE: Enhance 'pg_createsubscriber' to retrieve databases automatically when no database is provided. |
Date: | 2025-03-27 04:26:53 |
Message-ID: | OSCPR01MB149660B6D00665F47896CA812F5A12@OSCPR01MB14966.jpnprd01.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Dear Shubham,
Thanks for updating the patch!
> I agree that ensuring the correct order of objects (like publications)
> matching with databases is crucial, especially when explicitly
> specifying databases using -d switches.
> To address this, I have created a 0002 patch that aligns object
> creation order with the corresponding databases.
ISTM 0002 does completely different stuff. It handles the case when dbname is not
specified in -P. Commit message is also wrong.
Anyway, comments for 0001/0002:
01. connect_database
```
@@ -536,8 +541,9 @@ connect_database(const char *conninfo, bool exit_on_error)
conn = PQconnectdb(conninfo);
if (PQstatus(conn) != CONNECTION_OK)
{
- pg_log_error("connection to database failed: %s",
- PQerrorMessage(conn));
+ if (exit_on_error)
+ pg_log_error("connection to database failed: %s",
+ PQerrorMessage(conn));
PQfinish(conn);
```
Any error messages should not be suppressed. I imagine you've added this because
this command may try to connect to the postgres/template1, but this change affects
all other parts. I feel this change is not needed.
02. main()
```
+ if (opt.all_dbs)
+ {
+ bool dbnamespecified = (dbname_conninfo != NULL);
+
+ get_publisher_databases(&opt, dbnamespecified);
+ }
if (opt.database_names.head == NULL)
```
Need a blank between them. Ashutosh pointed out [1] because "else-if" was used in v21.
Now it becomes "if" again, the change must be reverted.
03. main()
```
- * If --database option is not provided, try to obtain the dbname from
- * the publisher conninfo. If dbname parameter is not available, error
- * out.
+ * If neither --database nor --all option is provided, try to obtain
+ * the dbname from the publisher conninfo. If dbname parameter is not
+ * available, error out.
```
This comment must be updated because we can reach here even when -a is specified.
Personally, since the pg_log_info() describes the situation, it is enough;
Try to obtain the dbname from the publisher conninfo. If dbname parameter is not
available, error out.
04.
```
+# run pg_createsubscriber with '--all' option
+my ($stdout, $stderr) = run_command(
+ [
+ 'pg_createsubscriber',
+ '--verbose',
+ '--dry-run',
+ '--recovery-timeout' => $PostgreSQL::Test::Utils::timeout_default,
+ '--pgdata' => $node_s->data_dir,
+ '--publisher-server' => $node_p->connstr($db1),
+ '--socketdir' => $node_s->host,
+ '--subscriber-port' => $node_s->port,
+ '--all',
+ ],
+ 'run pg_createsubscriber with --all');
```
We should test the case when -P does not contain dbname. IIUC, it is enough to use
`node_p->connstr` instead of `node_p->connstr($db1)`.
Best regards,
Hayato Kuroda
FUJITSU LIMITED
From | Date | Subject | |
---|---|---|---|
Next Message | Ashutosh Bapat | 2025-03-27 04:42:46 | Re: [PoC] Reducing planning time when tables have many partitions |
Previous Message | cca5507 | 2025-03-27 03:47:32 | Re: Historic snapshot doesn't track txns committed in BUILDING_SNAPSHOT state |