Re: speed up a logical replica setup
Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
pg_createsubscriber: Remove obsolete comment
- 71795d1cb41b 17.0 landed
- 1330843bb78e 18.0 landed
-
pg_createsubscriber: Fix an unpredictable recovery wait time.
- e5ba6a5ab62c 17.0 landed
- 03b08c8f5f3e 18.0 landed
-
Fix unstable test in 040_pg_createsubscriber.
- ae4e072bad5f 17.0 landed
- 9fd8b331dfe1 18.0 landed
-
Fix the testcase introduced in commit 81d20fbf7a.
- ae395f0f7edb 18.0 landed
- 14387ab06503 17.0 landed
-
Further weaken new pg_createsubscriber test on Windows.
- 55c309fc5b08 17.0 landed
- a1333ec048fb 18.0 landed
-
Temporarily(?) weaken new pg_createsubscriber test on Windows.
- 54508209178b 17.0 landed
-
Make pg_createsubscriber warn if publisher has two-phase commit enabled.
- 917754557cc0 17.0 landed
-
Make pg_createsubscriber more wary about quoting connection parameters.
- b3f5ccebd79d 17.0 landed
-
pg_createsubscriber: Remove failover replication slots on subscriber
- 81d20fbf7a03 17.0 landed
-
pg_createsubscriber: Remove replication slot check on primary
- b96391382626 17.0 landed
-
pg_createsubscriber: Only --recovery-timeout controls the end of recovery process
- 04c8634c0c4d 17.0 landed
-
pg_createsubscriber: creates a new logical replica from a standby server
- d44032d01463 17.0 landed
-
Add some const decorations
- 48018f1d8c12 17.0 landed
-
Add option force_initdb to PostgreSQL::Test::Cluster:init()
- ff9e1e764fcc 17.0 cited
-
Remove MSVC scripts
- 1301c80b2167 17.0 cited
Attachments
- 0001-fixup-Create-a-new-logical-replica-from-a-base-backu.patch (text/plain) patch 0001
On 21.02.22 13:09, Euler Taveira wrote:
> A new tool called pg_subscriber does this conversion and is tightly
> integrated
> with Postgres.
Are we comfortable with the name pg_subscriber? It seems too general.
Are we planning other subscriber-related operations in the future? If
so, we should at least make this one use a --create option or
something like that.
doc/src/sgml/ref/pg_subscriber.sgml
Attached is a patch that reorganizes the man page a bit. I moved the
description of the steps to the Notes section and formatted it
differently. I think the steps are interesting but not essential for
the using of the program, so I wanted to get them out of the main
description.
src/bin/pg_subscriber/pg_subscriber.c
+ if (made_temp_replslot)
+ {
+ conn = connect_database(dbinfo[0].pubconninfo, true);
+ drop_replication_slot(conn, &dbinfo[0], temp_replslot);
+ disconnect_database(conn);
+ }
Temp slots don't need to be cleaned up.
+/*
+ * Obtain the system identifier from control file. It will be used to
compare
+ * if a data directory is a clone of another one. This routine is used
locally
+ * and avoids a replication connection.
+ */
+static char *
+get_control_from_datadir(const char *datadir)
This could return uint64 directly, without string conversion.
get_sysid_from_conn() could then convert to uint64 internally.
+ {"verbose", no_argument, NULL, 'v'},
I'm not sure if the --verbose option is all that useful.
+ {"stop-subscriber", no_argument, NULL, 1},
This option doesn't seem to be otherwise supported or documented.
+ pub_sysid = pg_malloc(32);
+ pub_sysid = get_sysid_from_conn(dbinfo[0].pubconninfo);
+ sub_sysid = pg_malloc(32);
+ sub_sysid = get_control_from_datadir(subscriber_dir);
These mallocs don't appears to be of any use.
+ dbname_conninfo = pg_malloc(NAMEDATALEN);
This seems wrong.
Overall, this code could use a little bit more structuring. There are
a lot of helper functions that don't seem to do a lot and are mostly
duplicate runs-this-SQL-command calls. But the main() function is
still huge. There is room for refinement.
src/bin/pg_subscriber/t/001_basic.pl
Good start, but obviously, we'll need some real test cases here also.
src/bin/initdb/initdb.c
src/bin/pg_ctl/pg_ctl.c
src/common/file_utils.c
src/include/common/file_utils.h
I recommend skipping this refactoring. The readfile() function from
pg_ctl is not general enough to warrant the pride of place of a
globally available function. Note that it is specifically geared
toward some of pg_ctl's requirements, for example that the underlying
file can change while it is being read.
The requirements of pg_subscriber can be satisfied more easily: Just
call pg_ctl to start the server. You are already using that in
pg_subscriber. Is there a reason it can't be used here as well?