Skip to content

Commit 3ecdf01

Browse files
authored
Release v4.0.0 (patroni#3141)
- bump version - update release notes - adjust docs - bump pyright version - improve unit-test coverage
1 parent c9322df commit 3ecdf01

File tree

7 files changed

+128
-23
lines changed

7 files changed

+128
-23
lines changed

.github/workflows/tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ jobs:
186186

187187
- uses: jakebailey/pyright-action@v2
188188
with:
189-
version: 1.1.371
189+
version: 1.1.378
190190

191191
docs:
192192
runs-on: ubuntu-latest

docs/patronictl.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,25 +1940,25 @@ Get version of ``patronictl`` only:
19401940
.. code:: bash
19411941
19421942
$ patronictl -c postgres0.yml version
1943-
patronictl version 3.1.0
1943+
patronictl version 4.0.0
19441944
19451945
Get version of ``patronictl`` and of all members of cluster ``batman``:
19461946
19471947
.. code:: bash
19481948
19491949
$ patronictl -c postgres0.yml version batman
1950-
patronictl version 3.1.0
1950+
patronictl version 4.0.0
19511951
1952-
postgresql0: Patroni 3.1.0 PostgreSQL 15.2
1953-
postgresql1: Patroni 3.1.0 PostgreSQL 15.2
1954-
postgresql2: Patroni 3.1.0 PostgreSQL 15.2
1952+
postgresql0: Patroni 4.0.0 PostgreSQL 16.4
1953+
postgresql1: Patroni 4.0.0 PostgreSQL 16.4
1954+
postgresql2: Patroni 4.0.0 PostgreSQL 16.4
19551955
19561956
Get version of ``patronictl`` and of members ``postgresql1`` and ``postgresql2`` of cluster ``batman``:
19571957
19581958
.. code:: bash
19591959
19601960
$ patronictl -c postgres0.yml version batman postgresql1 postgresql2
1961-
patronictl version 3.1.0
1961+
patronictl version 4.0.0
19621962
1963-
postgresql1: Patroni 3.1.0 PostgreSQL 15.2
1964-
postgresql2: Patroni 3.1.0 PostgreSQL 15.2
1963+
postgresql1: Patroni 4.0.0 PostgreSQL 16.4
1964+
postgresql2: Patroni 4.0.0 PostgreSQL 16.4

docs/releases.rst

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,98 @@
33
Release notes
44
=============
55

6+
Version 4.0.0
7+
-------------
8+
9+
Released 2024-08-29
10+
11+
.. warning::
12+
- This version completes work on getting rid of the "master" term, in favor of "primary". This means a couple of breaking changes, please read the release notes carefully. Upgrading to the Patroni 4+ will work reliably only if you run Patroni 3.1.0 or newer. Upgrading from an older version directly to 4+ is possible but may lead to unexpected behavior if the primary fails while the rest of the nodes are running on other Patroni versions.
13+
14+
15+
**Breaking changes**
16+
17+
- The following breaking changes were introduced when getting rid of the non-inclusive "master" term in the Patroni code:
18+
19+
- On Kubernetes, Patroni by default will set ``role`` label to ``primary``. In case if you want to keep the old behavior and avoid downtime or lengthy complex migrations, you can configure parameters ``kubernetes.leader_label_value`` and ``kubernetes.standby_leader_label_value`` to ``master``. Read more :ref:`here <kubernetes_role_values>`.
20+
- Patroni role is written to DCS as ``primary`` instead of ``master``.
21+
- Patroni role returned by Patroni REST API has been changed from ``master`` to ``primary``.
22+
- Patroni REST API no longer accepts ``role=master`` in requests to ``/switchover``, ``/failover``, ``/restart`` endpoints.
23+
- ``/metrics`` REST API endpoint will no longer report ``patroni_master`` metric.
24+
- ``patronictl`` no longer accepts ``--master`` option for any command. ``--leader`` or ``--primary`` options should be used instead.
25+
- ``no_master`` option in the declarative configuration of custom replica creation methods is no longer treated as a special option, please use ``no_leader`` instead.
26+
- ``patroni_wale_restore`` script doesn't accept ``--no_master`` option anymore.
27+
- ``patroni_barman`` script doesn't accept ``--role=master`` option anymore.
28+
- All callback scripts are executed with ``role=primary`` option passed instead of ``role=master``.
29+
30+
- ``patronictl failover`` does not accept ``--leader`` option that was deprecated since Patroni 3.2.0.
31+
32+
- User creation functionality (``bootstrap.users`` configuration section) deprecated since Patroni 3.2.0 has been removed.
33+
34+
35+
**New features**
36+
37+
- Quorum-based failover (Ants Aasma, Alexander Kukushkin)
38+
39+
The feature implements quorum-based synchronous replication (available from PostgreSQL v10) which helps to reduce worst-case latencies, even during normal operation, as a higher latency of replicating to one standby can be compensated by other standbys. Patroni implements additional safeguards to prevent any user-visible data loss by choosing a failover candidate based on the latest transaction received.
40+
41+
- Register Citus secondaries in ``pg_dist_node`` (Alexander Kukushkin)
42+
43+
Patroni now maintains the list of nodes with ``role==replica``, ``state==running`` and without ``noloadbalance`` :ref:`tag <tags_settings>` in ``pg_dist_node``.
44+
45+
- Configurable retention of members' replication slots (Alexander Kukushkin)
46+
47+
Implements support of ``member_slots_ttl`` global configuration parameter that controls for how long member replication slots should be kept around when the member key is absent.
48+
49+
- Make permissions of log files created by Patroni configurable (Alexander Kukushkin)
50+
51+
Allows to set specific permissions for log files created by Patroni. If not specified, permissions are set based on the current ``umask`` value.
52+
53+
- Compatibility with PostgreSQL 17 beta3 (Alexander Kukushkin)
54+
55+
GUC's validator rules were extended. Patroni handles all the new auxiliary backends during shutdown and sets ``dbname`` in ``primary_conninfo``, as it is required for logical replication slots synchronization.
56+
57+
- Implement ``--ignore-listen-port`` option for Patroni config validation (Sahil Naphade)
58+
59+
Make it possible to ignore already bound ports when running ``patroni --validate-config``.
60+
61+
62+
**Improvements**
63+
64+
- Make ``wal_log_hints`` configurable (Paul_Kim)
65+
66+
Allows to avoid the overhead of ``wal_log_hints`` configuration being enabled in case ``use_pg_rewind`` is set to ``off``.
67+
68+
- Log ``pg_basebackup`` command in ``DEBUG`` level (Waynerv)
69+
70+
Facilitates failed initialization debugging.
71+
72+
73+
**Bugfixes**
74+
75+
- Advance permanent slots for cascading nodes while in failsafe (Alexander Kukushkin)
76+
77+
Ensure that slots for cascading replicas are properly advanced on the primary when failsafe mode is activated. It is done by extending replicas response on ``POST /failsafe`` REST API request with their ``xlog_location``.
78+
79+
- Don't let the current node be chosen as synchronous (Alexander Kukushkin)
80+
81+
There may be "something" streaming from the current primary node with ``application_name`` that matches the name of the current primary. Patroni was not properly handling this situation, which could end up in the primary being declared as a synchronous node and consequently was blocking switchovers.
82+
83+
- Ignore ``restapi.allowlist_include_members`` for POST /failsafe (Alexander Kukushkin)
84+
85+
- Improve GUCs validation (Polina Bungina)
86+
87+
Due to additional validation through running ``postgres --describe-config`` command, it was previously not possible to set GUCs not listed there through Patroni configuration. This limitation is now removed.
88+
89+
- Add line with ``localhost`` to ``.pgpass`` file when unix sockets are detected (Alexander Kukushkin)
90+
91+
Patroni will add an additional line to ``.pgpass`` file if ``host`` parameter specified starts with ``/`` character. This allows to cover a corner case when ``host`` matches the default socket directory path.
92+
93+
- Fix logging issues (Waynerv)
94+
95+
Defined proper request URL in failsafe handling logs and fixed the order of timestamps in postmaster check log.
96+
97+
698
Version 3.3.2
799
-------------
8100

docs/rest_api.rst

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ The ``GET /patroni`` is used by Patroni during the leader race. It also could be
103103
$ curl -s http://localhost:8008/patroni | jq .
104104
{
105105
"state": "running",
106-
"postmaster_start_time": "2024-08-18 11:03:37.966359+00:00",
106+
"postmaster_start_time": "2024-08-28 19:39:26.352526+00:00",
107107
"role": "primary",
108108
"server_version": 160004,
109109
"xlog": {
@@ -147,7 +147,7 @@ The ``GET /patroni`` is used by Patroni during the leader race. It also could be
147147
$ curl -s http://localhost:8008/patroni | jq .
148148
{
149149
"state": "running",
150-
"postmaster_start_time": "2024-08-18 11:09:08.615242+00:00",
150+
"postmaster_start_time": "2024-08-28 19:39:26.352526+00:00",
151151
"role": "replica",
152152
"server_version": 160004,
153153
"xlog": {
@@ -195,7 +195,7 @@ The ``GET /patroni`` is used by Patroni during the leader race. It also could be
195195
$ curl -s http://localhost:8008/patroni | jq .
196196
{
197197
"state": "running",
198-
"postmaster_start_time": "2024-08-18 11:09:08.615242+00:00",
198+
"postmaster_start_time": "2024-08-28 19:39:26.352526+00:00",
199199
"role": "replica",
200200
"server_version": 160004,
201201
"xlog": {
@@ -241,7 +241,7 @@ The ``GET /patroni`` is used by Patroni during the leader race. It also could be
241241
$ curl -s http://localhost:8008/patroni | jq .
242242
{
243243
"state": "running",
244-
"postmaster_start_time": "2024-08-18 11:09:08.615242+00:00",
244+
"postmaster_start_time": "2024-08-28 19:39:26.352526+00:00",
245245
"role": "replica",
246246
"server_version": 160004,
247247
"xlog": {
@@ -267,7 +267,7 @@ The ``GET /patroni`` is used by Patroni during the leader race. It also could be
267267
}
268268
],
269269
"pause": true,
270-
"dcs_last_seen": 1692356928,
270+
"dcs_last_seen": 1724874295,
271271
"tags": {
272272
"clonefrom": true
273273
},
@@ -293,7 +293,7 @@ Retrieve the Patroni metrics in Prometheus format through the ``GET /metrics`` e
293293
patroni_postgres_running{scope="batman",name="patroni1"} 1
294294
# HELP patroni_postmaster_start_time Epoch seconds since Postgres started.
295295
# TYPE patroni_postmaster_start_time gauge
296-
patroni_postmaster_start_time{scope="batman",name="patroni1"} 1657656955.179243
296+
patroni_postmaster_start_time{scope="batman",name="patroni1"} 1724873966.352526
297297
# HELP patroni_primary Value is 1 if this node is the leader, 0 otherwise.
298298
# TYPE patroni_primary gauge
299299
patroni_primary{scope="batman",name="patroni1"} 1
@@ -344,7 +344,7 @@ Retrieve the Patroni metrics in Prometheus format through the ``GET /metrics`` e
344344
patroni_postgres_timeline{scope="batman",name="patroni1"} 24
345345
# HELP patroni_dcs_last_seen Epoch timestamp when DCS was last contacted successfully by Patroni.
346346
# TYPE patroni_dcs_last_seen gauge
347-
patroni_dcs_last_seen{scope="batman",name="patroni1"} 1677658321
347+
patroni_dcs_last_seen{scope="batman",name="patroni1"} 1724874235
348348
# HELP patroni_pending_restart Value is 1 if the node needs a restart, 0 otherwise.
349349
# TYPE patroni_pending_restart gauge
350350
patroni_pending_restart{scope="batman",name="patroni1"} 1
@@ -492,12 +492,21 @@ Let's check that the node processed this configuration. First of all it should s
492492
493493
$ curl -s http://localhost:8008/patroni | jq .
494494
{
495-
"pending_restart": true,
496495
"database_system_identifier": "6287881213849985952",
497-
"postmaster_start_time": "2024-08-18 13:13:05.211 CEST",
496+
"postmaster_start_time": "2024-08-28 19:39:26.352526+00:00",
498497
"xlog": {
499498
"location": 2197818976
500499
},
500+
"timeline": 1,
501+
"dcs_last_seen": 1724874545,
502+
"database_system_identifier": "7408277255830290455",
503+
"pending_restart": true,
504+
"pending_restart_reason": {
505+
"max_connections": {
506+
"old_value": "100",
507+
"new_value": "101"
508+
}
509+
},
501510
"patroni": {
502511
"version": "4.0.0",
503512
"scope": "batman",

patroni/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
33
:var __version__: the current Patroni version.
44
"""
5-
__version__ = '3.3.2'
5+
__version__ = '4.0.0'

tests/test_bootstrap.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def test_bootstrap(self):
175175
with patch('subprocess.call', Mock(return_value=1)):
176176
self.assertFalse(self.b.bootstrap({}))
177177

178-
config = {'users': {'replicator': {'password': 'rep-pass', 'options': ['replication']}}}
178+
config = {}
179179

180180
with patch.object(Postgresql, 'is_running', Mock(return_value=False)), \
181181
patch.object(Postgresql, 'get_major_version', Mock(return_value=140000)), \
@@ -253,8 +253,12 @@ def test_post_bootstrap(self):
253253
self.assertFalse(task.result)
254254

255255
self.p.config._config.pop('pg_hba')
256-
self.b.post_bootstrap({}, task)
257-
self.assertTrue(task.result)
256+
with patch('patroni.postgresql.bootstrap.logger.error', new_callable=Mock()) as mock_logger:
257+
self.b.post_bootstrap({'users': 1}, task)
258+
self.assertEqual(mock_logger.call_args_list[0][0][0],
259+
'User creation is not be supported starting from v4.0.0. '
260+
'Please use "boostrap.post_bootstrap" script to create users.')
261+
self.assertTrue(task.result)
258262

259263
self.b.bootstrap(config)
260264
with patch.object(Postgresql, 'pending_restart_reason',

tests/test_citus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def setUp(self):
2222
self.cluster = get_cluster_initialized_with_leader()
2323
self.cluster.workers[1] = self.cluster
2424

25-
@patch('time.time', Mock(side_effect=[100, 130, 160, 190, 220, 250, 280, 310, 340, 370]))
25+
@patch('time.time', Mock(side_effect=[100, 130, 160, 190, 220, 250, 280, 310, 340, 370, 400, 430, 460, 490]))
2626
@patch('patroni.postgresql.mpp.citus.logger.exception', Mock(side_effect=SleepException))
2727
@patch('patroni.postgresql.mpp.citus.logger.warning')
2828
@patch('patroni.postgresql.mpp.citus.PgDistTask.wait', Mock())

0 commit comments

Comments
 (0)