Skip to content

Commit

Permalink
Release v3.3.1 (patroni#3087)
Browse files Browse the repository at this point in the history
* Update release notes
* Bump version
* Bump pyright version and solve reported issues

---------

Co-authored-by: Alexander Kukushkin <[email protected]>
  • Loading branch information
hughcapet and CyberDem0n authored Jun 17, 2024
1 parent d4fd782 commit 6b7ec49
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ jobs:

- uses: jakebailey/pyright-action@v2
with:
version: 1.1.356
version: 1.1.367

docs:
runs-on: ubuntu-latest
Expand Down
27 changes: 27 additions & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
Release notes
=============

Version 3.3.1
-------------

Released 2024-06-17

**Stability improvements**

- Compatibility with Python 3.12 (Alexander Kukushkin)

Handle a new attribute added to ``logging.LogRecord``.


**Bugfixes**

- Fix infinite recursion in ``replicatefrom`` tags handling (Alexander Kukushkin)

As a part of this fix, also improve ``is_physical_slot()`` check and adjust documentation.

- Fix wrong role reporting in standby clusters (Alexander Kukushkin)

`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.

- Fix availability of the ``allow_in_place_tablespaces`` GUC (Polina Bungina)

``allow_in_place_tablespaces`` was not only added to PostgreSQL 15 but also backpatched to PostgreSQL 10-14.


Version 3.3.0
-------------

Expand Down
22 changes: 16 additions & 6 deletions patroni/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ def error_exception(self: logging.Logger, msg: object, *args: Any, **kwargs: Any
self.error(msg, *args, exc_info=exc_info, **kwargs)


def _type(value: Any) -> str:
"""Get type of the *value*.
:param value: any arbitrary value.
:returns: a string with a type name.
"""
return value.__class__.__name__


class QueueHandler(logging.Handler):
"""Queue-based logging handler.
Expand Down Expand Up @@ -292,7 +301,7 @@ def _get_plain_formatter(self, logformat: type_logformat, dateformat: Optional[s
"""

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

return logging.Formatter(logformat, dateformat)
Expand Down Expand Up @@ -330,13 +339,13 @@ def _get_json_formatter(self, logformat: type_logformat, dateformat: Optional[st
else:
_LOGGER.warning(
'Expected renamed log field to be a string, but got "%s"',
type(renamed_field)
_type(renamed_field)
)

else:
_LOGGER.warning(
'Expected each item of log format to be a string or dictionary, but got "%s"',
type(field)
_type(field)
)

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

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

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

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

if logtype == 'json':
Expand Down
3 changes: 2 additions & 1 deletion patroni/postgresql/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ def escape(value: Any) -> str:
return re.sub(r'([:\\])', r'\\\1', str(value))

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

Expand Down
3 changes: 2 additions & 1 deletion patroni/postgresql/mpp/citus.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ def adjust_postgres_gucs(self, parameters: Dict[str, Any]) -> None:
# citus extension must be on the first place in shared_preload_libraries
shared_preload_libraries = list(filter(
lambda el: el and el != 'citus',
[p.strip() for p in parameters.get('shared_preload_libraries', '').split(',')]))
map(str.strip, parameters.get('shared_preload_libraries', '').split(',')))
) # pyright: ignore [reportUnknownArgumentType]
parameters['shared_preload_libraries'] = ','.join(['citus'] + shared_preload_libraries)

# if not explicitly set Citus overrides max_prepared_transactions to max_connections*2
Expand Down
2 changes: 1 addition & 1 deletion patroni/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
:var __version__: the current Patroni version.
"""
__version__ = '3.3.0'
__version__ = '3.3.1'
2 changes: 1 addition & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"reportMissingImports": true,
"reportMissingTypeStubs": false,

"pythonVersion": "3.11",
"pythonVersion": "3.12",
"pythonPlatform": "All",

"typeCheckingMode": "strict"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_invalid_dateformat(self):
self.assertEqual(captured_log_level, 'WARNING')
self.assertRegex(
captured_log_message,
fr'Expected log dateformat to be a string, but got "{type(config["dateformat"])}"'
r'Expected log dateformat to be a string, but got "int"'
)

def test_invalid_plain_format(self):
Expand Down

0 comments on commit 6b7ec49

Please sign in to comment.