Re: speed up a logical replica setup
Euler Taveira <euler@eulerto.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
- v2-0001-Creates-a-new-logical-replica-from-a-standby-serv.patch (text/x-patch) patch v2-0001
On Mon, Feb 21, 2022, at 9:09 AM, Euler Taveira wrote: > A new tool called pg_subscriber does this conversion and is tightly integrated > with Postgres. After a long period of inactivity, I'm back to this client tool. As suggested by Andres, I added a new helper function to change the system identifier as the last step. I also thought about including the pg_basebackup support but decided to keep it simple (at least for this current version). The user can always execute pg_basebackup as a preliminary step to create a standby replica and it will work. (I will post a separate patch that includes the pg_basebackup support on the top of this one.) Amit asked if an extra replication slot is required. It is not. The reason I keep it is to remember that at least the latest replication slot needs to be created after the pg_basebackup finishes (pg_backup_stop() call). Regarding the atexit() routine, it tries to do the best to remove all the objects it created, however, there is no guarantee it can remove them because it depends on external resources such as connectivity and authorization. I added a new warning message if it cannot drop the transient replication slot. It is probably a good idea to add such warning message into the cleanup routine too. More to this point, another feature that checks and remove all left objects. The transient replication slot is ok because it should always be removed at the end. However, the big question is how to detect that you are not removing objects (publications, subscriptions, replication slots) from a successful conversion. Amit also asked about setup a logical replica with m databases where m is less than the total number of databases. One option is to remove the "extra" databases in the target server after promoting the physical replica or in one of the latest steps. Maybe it is time to propose partial physical replica that contains only a subset of databases on primary. (I'm not volunteering to it.) Hence, pg_basebackup has an option to remove these "extra" databases so this tool can take advantage of it. Let's continue with the bike shedding... I agree with Peter E that this name does not express what this tool is. At the moment, it only have one action: create. If I have to suggest other actions I would say that it could support switchover option too (that removes the infrastructure created by this tool). If we decide to keep this name, it should be a good idea to add an option to indicate what action it is executing (similar to pg_recvlogical) as suggested by Peter. I included the documentation cleanups that Peter E shared. I also did small adjustments into the documentation. It probably deserves a warning section that advertises about the cleanup. I refactored the transient replication slot code and decided to use a permanent (instead of temporary) slot to avoid keeping a replication connection open for a long time until the target server catches up. The system identifier functions (get_control_from_datadir() and get_sysid_from_conn()) now returns uint64 as suggested by Peter. After reflection, the --verbose option should be renamed to --progress. There are also some messages that should be converted to debug messages. I fixed the useless malloc. I rearrange the code a bit but the main still has ~ 370 lines (without options/validation ~ 255 lines. I'm trying to rearrange the code to make the code easier to read and at the same time reduce the main size. I already have a few candidates in mind such as the code that stops the standby and the part that includes the recovery parameters. I removed the refactor I proposed in the previous patch and the current code is relying on pg_ctl --wait behavior. Are there issues with this choice? Well, one annoying situation is that pg_ctl does not have a "wait forever" option. If one of the pg_ctl calls fails, you could probably have to start again (unless you understand the pg_subscriber internals and fix the setup by yourself). You have to choose an arbitrary timeout value and expect that pg_ctl *does* perform the action less than the timeout. Real tests are included. The cleanup code does not have coverage because a simple reproducible case isn't easy. I'm also not sure if it is worth it. We can explain it in the warning section that was proposed. It is still a WIP but I would like to share it and get some feedback. -- Euler Taveira EDB https://www.enterprisedb.com/