RE: speed up a logical replica setup
Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.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
- v24-0001-Creates-a-new-logical-replica-from-a-standby-ser.patch (application/octet-stream) patch v24-0001
- v24-0002-Update-documentation.patch (application/octet-stream) patch v24-0002
- v24-0003-Add-version-check-for-standby-server.patch (application/octet-stream) patch v24-0003
- v24-0004-Remove-S-option-to-force-unix-domain-connection.patch (application/octet-stream) patch v24-0004
- v24-0005-Fix-some-trivial-issues.patch (application/octet-stream) patch v24-0005
- v24-0006-Fix-cleanup-functions.patch (application/octet-stream) patch v24-0006
- v24-0007-Fix-server_is_in_recovery.patch (application/octet-stream) patch v24-0007
- v24-0008-Avoid-possible-null-report.patch (application/octet-stream) patch v24-0008
- v24-0009-prohibit-to-reuse-publications.patch (application/octet-stream) patch v24-0009
- v24-0010-Make-the-ERROR-handling-more-consistent.patch (application/octet-stream) patch v24-0010
- v24-0011-Update-test-codes.patch (application/octet-stream) patch v24-0011
- v24-0012-Avoid-running-pg_createsubscriber-on-standby-whi.patch (application/octet-stream) patch v24-0012
- v24-0013-Consider-temporary-slot-to-check-max_replication.patch (application/octet-stream) patch v24-0013
- v24-0014-address-comments-from-Vignesh-1.patch (application/octet-stream) patch v24-0014
- v24-0015-Call-disconnect_database-even-when-the-process-w.patch (application/octet-stream) patch v24-0015
- v24-0016-Address-comments-From-Vignesh-2.patch (application/octet-stream) patch v24-0016
- v24-0017-Address-comments-From-Vignesh-3.patch (application/octet-stream) patch v24-0017
- v24-0018-Address-comments-From-Vignesh-4.patch (application/octet-stream) patch v24-0018
Dear Vignesh,
Since no one updates, here are new patch set.
Note that comments from Peter E. was not addressed because
Euler seemed to have already fixed.
> 3) Error conditions is verbose mode has invalid error message like
> "out of memory" messages like in below:
> pg_createsubscriber: waiting the postmaster to reach the consistent state
> pg_createsubscriber: postmaster reached the consistent state
> pg_createsubscriber: dropping publication "pg_createsubscriber_5" on
> database "postgres"
> pg_createsubscriber: creating subscription
> "pg_createsubscriber_5_278343" on database "postgres"
> pg_createsubscriber: error: could not create subscription
> "pg_createsubscriber_5_278343" on database "postgres": out of memory
Descriptions were added.
> 4) In error cases we try to drop this publication again resulting in error:
> + /*
> + * Since the publication was created before the
> consistent LSN, it is
> + * available on the subscriber when the physical
> replica is promoted.
> + * Remove publications from the subscriber because it
> has no use.
> + */
> + drop_publication(conn, &dbinfo[i]);
>
> Which throws these errors(because of drop publication multiple times):
> pg_createsubscriber: dropping publication "pg_createsubscriber_5" on
> database "postgres"
> pg_createsubscriber: error: could not drop publication
> "pg_createsubscriber_5" on database "postgres": ERROR: publication
> "pg_createsubscriber_5" does not exist
> pg_createsubscriber: dropping publication "pg_createsubscriber_5" on
> database "postgres"
> pg_createsubscriber: dropping the replication slot
> "pg_createsubscriber_5_278343" on database "postgres"
Changed to ... IF EXISTS. I thought your another proposal looked not good
because if the flag was turned off, the publication on publisher node could
not be dropped.
> 5) In error cases, wait_for_end_recovery waits even though it has
> identified that the replication between primary and standby is
> stopped:
> +/*
> + * Is recovery still in progress?
> + * If the answer is yes, it returns 1, otherwise, returns 0. If an error occurs
> + * while executing the query, it returns -1.
> + */
> +static int
> +server_is_in_recovery(PGconn *conn)
> +{
> + PGresult *res;
> + int ret;
> +
> + res = PQexec(conn, "SELECT pg_catalog.pg_is_in_recovery()");
> +
> + if (PQresultStatus(res) != PGRES_TUPLES_OK)
> + {
> + PQclear(res);
> + pg_log_error("could not obtain recovery progress");
> + return -1;
> + }
> +
>
> You can simulate this by stopping the primary just before
> wait_for_end_recovery and you will see these error messages, but
> pg_createsubscriber will continue to wait:
> pg_createsubscriber: error: could not obtain recovery progress
> pg_createsubscriber: error: could not obtain recovery progress
> pg_createsubscriber: error: could not obtain recovery progress
> pg_createsubscriber: error: could not obtain recovery progress
Based on idea from Euler, I roughly implemented. Thought?
0001-0013 were not changed from the previous version.
V24-0014: addressed your comment in the replied e-mail.
V24-0015: Add disconnect_database() again, per [3]
V24-0016: addressed your comment in [4].
V24-0017: addressed your comment in [5].
V24-0018: addressed your comment in [6].
[1]: https://www.postgresql.org/message-id/3ee79f2c-e8b3-4342-857c-a31b87e1afda%40eisentraut.org
[2]: https://www.postgresql.org/message-id/CALDaNm1ocVQmWhUJqxJDmR8N%3DCTbrH5GCdFU72ywnVRV6dND2A%40mail.gmail.com
[3]: https://www.postgresql.org/message-id/202402201053.6jjvdrm7kahf%40alvherre.pgsql
[4]: https://www.postgresql.org/message-id/CALDaNm2qHuZZvh6ym6OM367RfozU7RaaRDSm%3DF8M3SNrcQG2pQ%40mail.gmail.com
[5]: https://www.postgresql.org/message-id/CALDaNm3Q5W%3DEvphDjHA1n8ii5fv2DvxVShSmQLNFgeiHsOUwPg%40mail.gmail.com
[6]: https://www.postgresql.org/message-id/CALDaNm1M73ds0GBxX-XZX56f1D%2BGPojeCCwo-DLTVnfu8DMAvw%40mail.gmail.com
Best Regards,
Hayato Kuroda
FUJITSU LIMITED
https://www.fujitsu.com/