Re: speed up a logical replica setup
Ashutosh Bapat <ashutosh.bapat.oss@gmail.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
On Thu, Oct 26, 2023 at 5:17 PM Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> wrote: > > On Mon, Oct 23, 2023 at 9:34 AM Euler Taveira <euler@eulerto.com> wrote: > > > > > It is still a WIP but I would like to share it and get some feedback. > > > > > > I have started reviewing the patch. I have just read through all the > code. It's well documented and clear. Next I will review the design in > detail. Here are some comments about functionality and design. + <step> + <para> + <application>pg_subscriber</application> creates one replication slot for + each specified database on the source server. The replication slot name + contains a <literal>pg_subscriber</literal> prefix. These replication + slots will be used by the subscriptions in a future step. Another + replication slot is used to get a consistent start location. This + consistent LSN will be used as a stopping point in the <xref + linkend="guc-recovery-target-lsn"/> parameter and by the + subscriptions as a replication starting point. It guarantees that no + transaction will be lost. + </para> + </step> CREATE_REPLICATION_SLOT would wait for any incomplete transaction to complete. So it may not be possible to have an incomplete transaction on standby when it comes out of recovery. Am I correct? Can we please have a testcase where we test this scenario? What about a prepared transactions? + + <step> + <para> + <application>pg_subscriber</application> writes recovery parameters into + the target data directory and start the target server. It specifies a LSN + (consistent LSN that was obtained in the previous step) of write-ahead + log location up to which recovery will proceed. It also specifies + <literal>promote</literal> as the action that the server should take once + the recovery target is reached. This step finishes once the server ends + standby mode and is accepting read-write operations. + </para> + </step> At this stage the standby would have various replication objects like publications, subscriptions, origins inherited from the upstream server and possibly very much active. With failover slots, it might inherit replication slots. Is it intended that the new subscriber also acts as publisher for source's subscribers OR that the new subscriber should subscribe to the upstreams of the source? Some use cases like logical standby might require that but a multi-master multi-node setup may not. The behaviour should be user configurable. There may be other objects in this category which need special consideration on the subscriber. I haven't fully thought through the list of such objects. + uses the replication slot that was created in a previous step. The + subscription is created but it is not enabled yet. The reason is the + replication progress must be set to the consistent LSN but replication + origin name contains the subscription oid in its name. Hence, the Not able to understand the sentence "The reason is ... in its name". Why is subscription OID in origin name matters? + <para> + <application>pg_subscriber</application> stops the target server to change + its system identifier. + </para> I expected the subscriber to be started after this step. Why do we need pg_resetwal? + appendPQExpBuffer(str, "CREATE_REPLICATION_SLOT \"%s\"", slot_name); + appendPQExpBufferStr(str, " LOGICAL \"pgoutput\" NOEXPORT_SNAPSHOT"); Hardcoding output plugin name would limit this utility only to built-in plugin. Any reason for that limitation? In its current form the utility creates a logical subscriber which subscribes to all the tables (and sequences when we have sequence replication). But it will be useful even in case of selective replication from a very large database. In such a case the new subscriber will need to a. remove the unwanted objects b. subscriber will need to subscribe to publications publishing the "interesting" objects. We don't need to support this case, but the current functionality (including the interface) and design shouldn't limit us from doing so. Have you thought about this case? I noticed some differences between this and a similar utility https://github.com/2ndQuadrant/pglogical/blob/REL2_x_STABLE/pglogical_create_subscriber.c. I will be reviewing these differences next to see if we are missing anything here. -- Best Wishes, Ashutosh Bapat