From c2d46a084efcbf1bc3b1b48f6ba306f5c1df8e7e Mon Sep 17 00:00:00 2001 From: Feike Steenbergen Date: Fri, 5 Feb 2016 09:22:38 +0100 Subject: [PATCH 1/2] Include timestamp of last replayed location in api call. --- patroni/api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/patroni/api.py b/patroni/api.py index 2318fbf0..3137a829 100644 --- a/patroni/api.py +++ b/patroni/api.py @@ -229,6 +229,7 @@ class RestApiHandler(BaseHTTPRequestHandler): END, pg_xlog_location_diff(pg_last_xlog_receive_location(), '0/0')::bigint, pg_xlog_location_diff(pg_last_xlog_replay_location(), '0/0')::bigint, + to_char(pg_last_xact_replay_timestamp(), 'YYYY-MM-DD HH24:MI:SS.MS TZ'), pg_is_in_recovery() AND pg_is_xlog_replay_paused()""", retry=retry)[0] return { 'state': self.server.patroni.postgresql.state, @@ -238,7 +239,8 @@ class RestApiHandler(BaseHTTPRequestHandler): 'xlog': ({ 'received_location': row[3], 'replayed_location': row[4], - 'paused': row[5]} if row[1] else { + 'replayed_timestamp': row[5], + 'paused': row[6]} if row[1] else { 'location': row[2] }) } From de129b733d27f2704371f054eb90350ba17adb30 Mon Sep 17 00:00:00 2001 From: Alexander Kukushkin Date: Wed, 17 Feb 2016 12:46:32 +0100 Subject: [PATCH 2/2] Fix unit tests --- tests/test_postgresql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_postgresql.py b/tests/test_postgresql.py index 4c701c60..a63a90cc 100644 --- a/tests/test_postgresql.py +++ b/tests/test_postgresql.py @@ -38,7 +38,7 @@ class MockCursor(object): elif sql == 'SELECT pg_is_in_recovery()': self.results = [(False, )] elif sql.startswith('SELECT to_char(pg_postmaster_start_time'): - self.results = [('', True, '', '', '', False)] + self.results = [('', True, '', '', '', '', False)] else: self.results = [( None,