Skip to content

Commit 9ffc4fc

Browse files
hughcapetCyberDem0n
andcommitted
Release v3.3.1 (patroni#3087)
* Update release notes * Bump version * Bump pyright version and solve reported issues --------- Co-authored-by: Alexander Kukushkin <cyberdemn@gmail.com>
1 parent 4b0b5ac commit 9ffc4fc

File tree

8 files changed

+51
-12
lines changed

8 files changed

+51
-12
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.356
189+
version: 1.1.367
190190

191191
docs:
192192
runs-on: ubuntu-latest

docs/releases.rst

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

6+
Version 3.3.1
7+
-------------
8+
9+
Released 2024-06-17
10+
11+
**Stability improvements**
12+
13+
- Compatibility with Python 3.12 (Alexander Kukushkin)
14+
15+
Handle a new attribute added to ``logging.LogRecord``.
16+
17+
18+
**Bugfixes**
19+
20+
- Fix infinite recursion in ``replicatefrom`` tags handling (Alexander Kukushkin)
21+
22+
As a part of this fix, also improve ``is_physical_slot()`` check and adjust documentation.
23+
24+
- Fix wrong role reporting in standby clusters (Alexander Kukushkin)
25+
26+
`synchronous_standby_names` and synchronous replication only work on a real primary node and in the case of cascading replication are simply ignored by Postgres. Before this fix, `patronictl list` and `GET /cluster` were falsely reporting some nodes as synchronous.
27+
28+
- Fix availability of the ``allow_in_place_tablespaces`` GUC (Polina Bungina)
29+
30+
``allow_in_place_tablespaces`` was not only added to PostgreSQL 15 but also backpatched to PostgreSQL 10-14.
31+
32+
633
Version 3.3.0
734
-------------
835

patroni/log.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ def error_exception(self: logging.Logger, msg: object, *args: Any, **kwargs: Any
6262
self.error(msg, *args, exc_info=exc_info, **kwargs)
6363

6464

65+
def _type(value: Any) -> str:
66+
"""Get type of the *value*.
67+
68+
:param value: any arbitrary value.
69+
:returns: a string with a type name.
70+
"""
71+
return value.__class__.__name__
72+
73+
6574
class QueueHandler(logging.Handler):
6675
"""Queue-based logging handler.
6776
@@ -292,7 +301,7 @@ def _get_plain_formatter(self, logformat: type_logformat, dateformat: Optional[s
292301
"""
293302

294303
if not isinstance(logformat, str):
295-
_LOGGER.warning('Expected log format to be a string when log type is plain, but got "%s"', type(logformat))
304+
_LOGGER.warning('Expected log format to be a string when log type is plain, but got "%s"', _type(logformat))
296305
logformat = PatroniLogger.DEFAULT_FORMAT
297306

298307
return logging.Formatter(logformat, dateformat)
@@ -330,13 +339,13 @@ def _get_json_formatter(self, logformat: type_logformat, dateformat: Optional[st
330339
else:
331340
_LOGGER.warning(
332341
'Expected renamed log field to be a string, but got "%s"',
333-
type(renamed_field)
342+
_type(renamed_field)
334343
)
335344

336345
else:
337346
_LOGGER.warning(
338347
'Expected each item of log format to be a string or dictionary, but got "%s"',
339-
type(field)
348+
_type(field)
340349
)
341350

342351
if len(log_fields) > 0:
@@ -346,11 +355,12 @@ def _get_json_formatter(self, logformat: type_logformat, dateformat: Optional[st
346355
else:
347356
jsonformat = PatroniLogger.DEFAULT_FORMAT
348357
rename_fields = {}
349-
_LOGGER.warning('Expected log format to be a string or a list, but got "%s"', type(logformat))
358+
_LOGGER.warning('Expected log format to be a string or a list, but got "%s"', _type(logformat))
350359

351360
try:
352361
from pythonjsonlogger import jsonlogger
353-
if hasattr(jsonlogger, 'RESERVED_ATTRS') and 'taskName' not in jsonlogger.RESERVED_ATTRS:
362+
if hasattr(jsonlogger, 'RESERVED_ATTRS') \
363+
and 'taskName' not in jsonlogger.RESERVED_ATTRS: # pyright: ignore [reportUnnecessaryContains]
354364
# compatibility with python 3.12, that added a new attribute to LogRecord
355365
jsonlogger.RESERVED_ATTRS += ('taskName',)
356366

@@ -380,7 +390,7 @@ def _get_formatter(self, config: Dict[str, Any]) -> logging.Formatter:
380390
static_fields = config.get('static_fields', {})
381391

382392
if dateformat is not None and not isinstance(dateformat, str):
383-
_LOGGER.warning('Expected log dateformat to be a string, but got "%s"', type(dateformat))
393+
_LOGGER.warning('Expected log dateformat to be a string, but got "%s"', _type(dateformat))
384394
dateformat = None
385395

386396
if logtype == 'json':

patroni/postgresql/config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,8 @@ def escape(value: Any) -> str:
885885
return re.sub(r'([:\\])', r'\\\1', str(value))
886886

887887
# 'host' could be several comma-separated hostnames, in this case we need to write on pgpass line per host
888-
hosts = map(escape, filter(None, map(str.strip, (record.get('host') or '*').split(','))))
888+
hosts = map(escape, filter(None, map(str.strip,
889+
(record.get('host', '') or '*').split(',')))) # pyright: ignore [reportUnknownArgumentType]
889890
record = {n: escape(record.get(n) or '*') for n in ('port', 'user', 'password')}
890891
return '\n'.join('{host}:{port}:*:{user}:{password}'.format(**record, host=host) for host in hosts)
891892

patroni/postgresql/mpp/citus.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ def adjust_postgres_gucs(self, parameters: Dict[str, Any]) -> None:
428428
# citus extension must be on the first place in shared_preload_libraries
429429
shared_preload_libraries = list(filter(
430430
lambda el: el and el != 'citus',
431-
[p.strip() for p in parameters.get('shared_preload_libraries', '').split(',')]))
431+
map(str.strip, parameters.get('shared_preload_libraries', '').split(',')))
432+
) # pyright: ignore [reportUnknownArgumentType]
432433
parameters['shared_preload_libraries'] = ','.join(['citus'] + shared_preload_libraries)
433434

434435
# if not explicitly set Citus overrides max_prepared_transactions to max_connections*2

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.0'
5+
__version__ = '3.3.1'

pyrightconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"reportMissingImports": true,
2020
"reportMissingTypeStubs": false,
2121

22-
"pythonVersion": "3.11",
22+
"pythonVersion": "3.12",
2323
"pythonPlatform": "All",
2424

2525
"typeCheckingMode": "strict"

tests/test_log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def test_invalid_dateformat(self):
187187
self.assertEqual(captured_log_level, 'WARNING')
188188
self.assertRegex(
189189
captured_log_message,
190-
fr'Expected log dateformat to be a string, but got "{type(config["dateformat"])}"'
190+
r'Expected log dateformat to be a string, but got "int"'
191191
)
192192

193193
def test_invalid_plain_format(self):

0 commit comments

Comments
 (0)