launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25323
[Merge] ~twom/launchpad:fix-getreplication-lag into launchpad:master
Tom Wardill has proposed merging ~twom/launchpad:fix-getreplication-lag into launchpad:master.
Commit message:
Swap hot_standby for pg_is_in_recovery
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/391040
Postgres 10 changes the default of `hot_standby` on `on`.
Change it for `pg_is_in_recovery` as that gives us the behaviour we want of telling us if there is actually a standby.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:fix-getreplication-lag into launchpad:master.
diff --git a/lib/lp/services/database/policy.py b/lib/lp/services/database/policy.py
index 066fdb3..691baf4 100644
--- a/lib/lp/services/database/policy.py
+++ b/lib/lp/services/database/policy.py
@@ -358,7 +358,7 @@ class LaunchpadDatabasePolicy(BaseDatabasePolicy):
slave_store = self.getStore(MAIN_STORE, SLAVE_FLAVOR)
hot_standby, streaming_lag = slave_store.execute("""
SELECT
- current_setting('hot_standby') = 'on',
+ pg_is_in_recovery(),
now() - pg_last_xact_replay_timestamp()
""").get_one()
if hot_standby and streaming_lag is not None: