Skip to content

Commit 651fe5d

Browse files
committed
Add support for cascading replication
1 parent 60f65b2 commit 651fe5d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.rst

+30
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,36 @@ PG database connection strings that the pglookout process should monitor.
221221
Keys of the object should be names of the remotes and values must be valid
222222
PostgreSQL connection strings or connection info objects.
223223

224+
``cascading_replication_primary`` (default ``null``)
225+
226+
Makes pglookout to consider matching instance as primary even though PG on
227+
the node is in recovery mode. This allows setting cascading replication like
228+
this::
229+
230+
Active cluster1 DR cluster 2
231+
+---------------------+ +-------------------------+
232+
| primary1 (writable) |<---------------| primary2 (non-writable) |
233+
+---------------------+ +-------------------------+
234+
^ ^ ^ ^
235+
| | | |
236+
+------------+ +------------+ +------------+ +------------+
237+
| secondary1 | | secondary2 | | secondary3 | | secondary4 |
238+
+------------+ +------------+ +------------+ +------------+
239+
240+
In a setup like this, the DR cluster 2 could replace the active cluster as
241+
a whole in case the active cluster runs in a region that becomes unavailable.
242+
The ``primary2``, which is not writable and not really a primary in that sense, but
243+
may be promoted as an actual writable primary in case all nodes in the active
244+
cluster 1 fail, is observing the state of ``primary1``, ``secondary1`` and ``secondary2``.
245+
246+
``secondary3`` and ``secondary4`` in the DR cluster 2 need to be configured to replicate
247+
from ``primary2`` and need to monitor the availability of that so that they can
248+
take over should it fail. However, as ``primary2`` is not writable it would not by
249+
default be considered to be a master node and replication would not get
250+
configured correctly nor would availability monitoring work as expected.
251+
Setting ``cascading_replication_primary=primary2`` for ``secondary3`` and ``secondary4``
252+
makes this configuration work as expected.
253+
224254
``primary_conninfo_template``
225255

226256
Connection string or connection info object template to use when setting a new

pglookout/cluster_monitor.py

+2
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ def _query_cluster_member_state(self, instance, db_conn):
297297

298298
if f_result:
299299
result.update(self._parse_status_query_result(f_result))
300+
if instance == self.config.get("cascading_replication_primary") and "pg_is_in_recovery" in result:
301+
result["pg_is_in_recovery"] = False
300302
return result
301303

302304
@staticmethod

0 commit comments

Comments
 (0)