pgsql: Use WAIT FOR LSN in PostgreSQL::Test::Cluster::wait_for_catchup(
| От | Alexander Korotkov |
|---|---|
| Тема | pgsql: Use WAIT FOR LSN in PostgreSQL::Test::Cluster::wait_for_catchup( |
| Дата | |
| Msg-id | E1w9pvB-003HW2-1E@gemulon.postgresql.org обсуждение |
| Ответы |
Re: pgsql: Use WAIT FOR LSN in PostgreSQL::Test::Cluster::wait_for_catchup(
|
| Список | pgsql-committers |
Use WAIT FOR LSN in PostgreSQL::Test::Cluster::wait_for_catchup() When the standby is passed as a PostgreSQL::Test::Cluster instance, use the WAIT FOR LSN command on the standby server to implement wait_for_catchup() for replay, write, and flush modes. This is more efficient than polling pg_stat_replication on the upstream, as the WAIT FOR LSN command uses a latch-based wakeup mechanism. The optimization applies when: - The standby is passed as a Cluster object (not just a name string) - The mode is 'replay', 'write', or 'flush' (not 'sent') Rather than pre-checking pg_is_in_recovery() on the standby (which would add an extra round-trip on every call), we issue WAIT FOR LSN directly and handle the 'not in recovery' result as a signal to fall back to polling. For 'sent' mode, when the standby is passed as a string (e.g., a subscription name for logical replication), when the standby has been promoted, or when WAIT FOR LSN is interrupted by a recovery conflict, the function falls back to the original polling-based approach using pg_stat_replication on the upstream. The recovery conflict fallback is necessary because some conflicts are unavoidable - for example, ResolveRecoveryConflictWithTablespace() kills all backends unconditionally, regardless of what they are doing. The recovery conflict detection matches the English error message "conflict with recovery", which is reliable because the test suite runs with LC_MESSAGES=C. Discussion: https://postgr.es/m/CABPTF7UiArgW-sXj9CNwRzUhYOQrevLzkYcgBydmX5oDes1sjg%40mail.gmail.com Author: Xuneng Zhou <xunengzhou@gmail.com> Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: Alvaro Herrera <alvherre@kurilemu.de> Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/7e8aeb9e483db48500987da8981a70b491b7844c Modified Files -------------- src/test/perl/PostgreSQL/Test/Cluster.pm | 108 ++++++++++++++++++++++++++++--- 1 file changed, 100 insertions(+), 8 deletions(-)
В списке pgsql-committers по дате отправления: