Commit Graph
2485 Commits
Author SHA1 Message Date
Polina BunginaandGitHub 3d932e1e73 Temp revert of "Enable behave tests with Citus 13 and PostgreSQL 17" (#3265)
but keep timeout increase
2025-02-03 08:44:02 +01:00
Alexander KukushkinandGitHub 38aef484e8 Fix a few little issues with 9.5 support (#3260)
1. pg_rewind error log format wasn't verbose
2. it doesn't support specifying num in synchronous_standby_names
2025-01-31 16:46:07 +01:00
Alexander KukushkinandGitHub 34b2a77294 Fix race condition in priority sync behave tests (#3263)
don't try patching /config key before leader managed to create it.
2025-01-31 16:45:26 +01:00
Alexander KukushkinandGitHub 6caa2fa99c Enable behave tests with Citus 13 and PostgreSQL 17 (#3262)
Also increase timeout from 15m to 20m
2025-01-31 16:44:32 +01:00
Joe JensenandGitHub b4eab48971 Fall through to default behavior when pyinstall toc is not found (#3256)
Close #3255
2025-01-31 10:14:27 +01:00
Alexander KukushkinandGitHub 2bc25a32e4 Avoid dropping physical slots too early (#3244)
Consider a situation: there is a permanent logical slot and primary and replica are temporary down.
When Patroni is started on the former primary it starts Postgres in a standby mode, what leads to removal of physical replication slot for the replica because it has xmin.

We should postpone removal of such physical slots:
- on replica until there will be a leader in the cluster
- on primary until Postgres is promoted
2025-01-30 13:08:30 +01:00
Alexander KukushkinandGitHub 7db7dfd3c5 Compatibility with python 3.13 (#3246)
- fix unit tests (logging now uses time.time_ns() instead of time.time())
- update setup.py
- update tox.ini
- enable unix and behave tests with 3.13

Close https://github.com/patroni/patroni/issues/3243
2025-01-20 08:58:12 +01:00
Antoni MurandGitHub 3938bb9a16 Replace forward slash in cluster_name (#3247) 2025-01-20 08:57:48 +01:00
JulianandGitHub 26ae38960a Improve error on empty or non dict config file (#3238)
Test if config (file) parsed with yaml_load() contains a valid Mapping
object, otherwise Patroni throws an explicit exception. It also makes
the Patroni output more explicit when using that kind of "invalid"
configuration.

``` console
$ touch /tmp/patroni.yaml
$ patroni --validate-config /tmp/patroni.yaml
/tmp/patroni.yaml does not contain a dict
invalid config file /tmp/patroni.yaml
```
reportUnnecessaryIsInstance is explicitly ignored since we can't
determine what yaml_safeload can bring from a YAML config (list,
dict,...).
2025-01-17 14:44:47 +01:00
Alexander KukushkinandGitHub 836e527e6d Fix deps compatibility, increase tests coverage i(#3233)
* Compatibility with python-json-logger>=3.1

After refactoring the old API is still working, but producing warnings
and pyright also fails.

Besides that improve coverage of watchdog/base.py and ctl.py

* Stick to ubuntu 22.04

* Please pyright
2024-12-24 09:11:17 +01:00
Alexander KukushkinandGitHub e73f2044c8 Cancel long-running jobs on Patroni stop (#3232)
Patroni could be doing replica bootstrap and we don't want want pg_basebackup/wal-g/pgBackRest/barman or similar keep running.

Besides that, remove data directory on replica bootstrap failure if configuration allows.

Close #3224
2024-12-12 09:52:03 +01:00
Polina BunginaandGitHub 39f5de2e77 Implement sync_priority tag (#3223) 2024-12-10 14:57:47 +01:00
avandrasandGitHub 46e20edbc2 Show only the members to be restarted upon restart confirmation (#3226)
When doing `patronictl restart <clustername> --pending`, the confirmation lists all members, regardless if their restart is really pending:

```
> patronictl restart pgcluster --pending
+ Cluster: pgcluster (7436691039717365672) ----+----+-----------+-----------------+---------------------------------+
| Member | Host     | Role         | State     | TL | Lag in MB | Pending restart | Pending restart reason          |
+--------+----------+--------------+-----------+----+-----------+-----------------+---------------------------------+
| win1   | 10.0.0.2 | Sync Standby | streaming |  8 |         0 | *               | hba_file: [hidden - too long]   |
|        |          |              |           |    |           |                 | ident_file: [hidden - too long] |
|        |          |              |           |    |           |                 | max_connections: 201->202       |
+--------+----------+--------------+-----------+----+-----------+-----------------+---------------------------------+
| win2   | 10.0.0.3 | Leader       | running   |  8 |           | *               | hba_file: [hidden - too long]   |
|        |          |              |           |    |           |                 | ident_file: [hidden - too long] |
|        |          |              |           |    |           |                 | max_connections: 201->202       |
+--------+----------+--------------+-----------+----+-----------+-----------------+---------------------------------+
| win3   | 10.0.0.4 | Replica      | streaming |  8 |         0 |                 |                                 |
+--------+----------+--------------+-----------+----+-----------+-----------------+---------------------------------+
When should the restart take place (e.g. 2024-11-27T08:27)  [now]:
Restart if the PostgreSQL version is less than provided (e.g. 9.5.2)  []:
Are you sure you want to restart members win1, win2, win3? [y/N]:
```

When we proceed with the restart despite the scary message mentioning all members, not just the ones needing a restart, there will be an error message stating the node not to be restarted was indeed not restarted:

```
Are you sure you want to restart members win1, win2, win3? [y/N]: y
Restart if the PostgreSQL version is less than provided (e.g. 9.5.2)  []:
Success: restart on member win1
Success: restart on member win2
Failed: restart for member win3, status code=503, (restart conditions are not satisfied)
```

The misleading confirmation message can also be seen when using the `--any` flag.

The current PR is fixing this.

However, we do not apply filtering in case of scheduled pending restart, because the condition must be evaluated at the scheduled time.
2024-12-10 12:04:47 +01:00
Michael BanckandGitHub 578dc39291 Add optional 'cluster_type' attribute to permanent replication slots. (#3229)
This allows to set whether a particular permanent replication slot should always be created ('cluster_type=any', the default), or just on a primary ('cluster_type=primary') or standby ('cluster_type=standby') cluster, respectively.
2024-12-10 11:55:59 +01:00
Ants AasmaandGitHub 9d1609e0eb Reduce log level of watchdog configuration failure (#3231)
When in automatic mode we probably don't need to warn user about failure to set up watchdog. This is the common case and makes many users think that this feature is somehow necessary to run Patroni safely. For most users it is completely fine to run without and it makes sense to reduce their log spam.
2024-12-10 11:54:27 +01:00
Polina BunginaandGitHub fb0fcc859a Release v4.0.4 (#3221)
* Release v4.0.4

- Increase version
- Use latest pyright
- Add RNs
2024-11-22 14:29:59 +01:00
Alexander KukushkinandGitHub a903438a5a Compatibility with ydiff==1.4.2 (#3216)
1. Implemented compatibility.
2. Constrained the upper version in requirements.txt to avoid future failures.
3. Setup an additional pipeline to check with the latest ydiff.

Close #3209
Close #3212
Close #3218
2024-11-19 09:27:49 +01:00
Alexander KukushkinandGitHub 19f75b407e Compatibility with prettytable>=3.12.0 (#3217)
They started showing deprecation warning when importing ALL and FRAME constants.
2024-11-19 09:09:09 +01:00
Alexander KukushkinandGitHub 3f00b7a6c7 Restore compatibility with python-consul2 (#3215)
It was broken in #3191
2024-11-19 09:08:50 +01:00
Kian-Meng AngandGitHub 4ce0f99cfb Fix typos (#3204)
Found via `codespell -H` and `typos --hidden --format brief`
2024-11-12 10:06:53 +01:00
Alexander KukushkinandGitHub efba02f52e Make sure only supported parameters are written to connection string (#3207)
Close #3206
2024-11-12 09:24:30 +01:00
Alexander KukushkinandGitHub e1faa38e90 Cache DCS instances to avoid thread leak in patronictl list -W (#3205)
Close #3202
2024-11-11 13:59:27 +01:00
bocytkoandGitHub 177101a1cc Fixes outdated link to Zalando's tech blog on Patroni (#3201) 2024-11-05 09:44:27 +01:00
7dcb9b9840 Run on_role_change cb after a failed primary recovery (#3198)
Additionally run on_role_change callback in post_recover() for a primary
that failed to start after a crash to increase chances the callback is executed,
even if the further start as a replica fails

---------

Co-authored-by: Alexander Kukushkin <[email protected]>
2024-10-31 09:22:51 +01:00
Alexander KukushkinandGitHub e8a8bfe42f Switch to py-consul (#3191)
python-consul is unmaintained for a long time and py-consul is an official replacement.
However, we still keep backward compatibility with python-consul.

Close: #3189
2024-10-28 09:58:57 +01:00
Denis LaxaldeandGitHub 72be036c99 Fix defaults 'max_wal_senders' and 'max_replication_slots' in docs (#3192)
From the actual code, in patroni/postgresql/config.py::ConfigHandler.CMDLINE_OPTIONS,
the previous defaults were wrong.
2024-10-25 11:18:45 +02:00
Polina BunginaandGitHub 969d7ec4ab Increase version, add RNs (#3188) 2024-10-18 13:42:42 +02:00
Polina BunginaandGitHub 75ff8b3256 Add documentation for sslnegotiation option (#3185) 2024-10-18 09:27:19 +02:00
Alexander KukushkinandGitHub 4853b3b430 Pyright 1.1.385 (#3182)
Declaring variables with `Union` and using `isinstance()` hack doesn't work anymore. Therefore the code is updated to use `Any` for variable and `cast` function after firguring out the correct type in order to avoid getting errors about `Unknown` types.
2024-10-18 09:24:51 +02:00
Polina BunginaandGitHub ba970d8c63 Temporary pin psycopg2-binary version for macOS (#3186) 2024-10-18 08:44:28 +02:00
Polina BunginaandGitHub ff278705d6 Partially revert patroni@8c5ab4c (#3180)
Still check against `postgres --describe-config` if a GUC does not have
a validator but is a valid postgres GUC
2024-10-16 11:13:25 +02:00
Alexander KukushkinandGitHub 74c0acf36d Fix issue with mixed setups: primary on pre-v4 and replicas on v4+ (#3181)
Reported in #3171
2024-10-16 11:00:29 +02:00
Polina BunginaandGitHub 58ee52b401 Docs compatibility with sphinx 8 (#3177) 2024-10-10 11:06:55 +02:00
kvisetandGitHub 877acf2a55 Disable pgaudit when creating users to not expose password (#3175)
pgaudit could be added to shared_preload_libraries, but we don't check for it, because setting a custom GUC works in all cases.
2024-10-09 11:57:38 +02:00
Alexander KukushkinandGitHub 8e46086335 Recheck annotations when reading leader object on 409 (#3174)
There are cases when we may send the same PATCH request more than one time to K8s API server and it could happen that the first request actually successfully updated the target and we cancelled while waiting for a response. The second PATCH request in this case will fail due to resource_version mismatch.

So far our strategy for update_leader() method was - re-read the object and repeat the request with the new resource_version. However, we can avoid the update by comparing annotations on the read object with annotations that we wanted to set.
2024-10-02 15:06:12 +02:00
Alexander KukushkinandGitHub e91e6b5484 Add support of sslnegotiation client-side connection option (#3173)
It is available in PostgreSQL 17

Besides that, enable PG17 in behave tests and include PG17 to supported versions in docs.
2024-09-27 11:27:09 +02:00
Polina BunginaandGitHub 6b685036d0 Release v4.0.2 (#3166)
- Increase version
- Use newer pyright (not latest)
- Add RNs
2024-09-17 16:24:50 +02:00
Alexander KukushkinandGitHub 78a46b9ebc Follow up on #3148 (#3167)
the original fix didn't address same problem with with permanent slots,
but only the part with member slots being retained due to
`member_slots_ttl`.
2024-09-17 12:02:12 +02:00
Alexander KukushkinandGitHub d7e172c20a Don't retains member slots on nodes with nofailover tag (#3169)
Followup on #3142
2024-09-17 11:21:54 +02:00
Brian HartfordandGitHub 87cb7481ae Fix timeline metric None value (#3165)
Close #3164
2024-09-17 10:06:37 +02:00
Alexander KukushkinandGitHub bfa9b0ca4b Fix flake8 for tests directory (#3168)
Followup on #3123
2024-09-16 17:20:00 +02:00
Alexander KukushkinandGitHub 416a0f7c8b Use names with "unusual" symbols in behave tests (#3162)
It'll hopefully prevent problems like #3142 in future.
2024-09-16 09:35:22 +02:00
hadizamani021andGitHub 94a592d275 Fix keepalive connection out of the range issue (#3089) (#3158) 2024-09-13 17:48:59 +02:00
Alexander KukushkinandGitHub 74a72e4f78 Fix bug in quote_standby_name() function (#3161)
According to Postgres docs "ANY" and "FIRST" keywords are supposed to be double-quoted.

Ref: https://www.postgresql.org/docs/current/runtime-config-replication.html#GUC-SYNCHRONOUS-STANDBY-NAMES
2024-09-13 14:21:22 +02:00
Michael BanckandGitHub 4c951a2937 Ensure sphinx doc attributes are available before trying to access them (#3156)
Very old versions of sphinx (e.g. as shipped in Ubuntu 20.04 LTS) might not have them.

Close #3155
2024-09-12 10:08:05 +02:00
Alexander KukushkinandGitHub b3ae8652c9 Explicitly include CMDLINE_OPTIONS GUCs when querying pg_settings (#3157)
followup on #2993
2024-09-12 10:07:07 +02:00
Alexander KukushkinandGitHub 66f98c80e8 Use None instead of empty string in socket.getaddrinfo() port (#3160)
The only reason there was an empty string is python 2.7 compatibility.

Close #3144
2024-09-12 10:06:43 +02:00
WaynervandGitHub 57ed40f66c Fix unhandled DCSError during startup phase (#3149)
Ensure DCS connectivity before we check node uniqueness or load dynamic configuration.
2024-09-12 08:55:05 +02:00
d5d6a51e2c Make sure inactive hot physical replication slots don't hold xmin (#3148)
Since `3.2.0` Patroni is able to create physical replication slots on replica nodes just for the case if this node at some moment will become the primary.
There are two potential problems of having such slots:
1. They prevent recycling of WAL files.
2. They may affect vacuum on the primary is hot_standby_feedback is enabled.

The first class of issues is already addressed by periodically calling pg_replication_slot_advance() function.
However the second class of issues doesn't happen instantly, but only when the old primary switched to a replica. In this case physical replication slots that were at some moment activate will hold NOT NULL value of `xmin`, which will be propagated to the primary via hot_standby_feedback mechanism.

To address the second problem we will detect that a physical replication slot is not supposed to be active, but having NOT NULL `xmin` and drop/crecreate it.

Close #3146
Close #3153

Co-authored-by: Polina Bungina <[email protected]>
2024-09-10 08:24:26 +02:00
Alexander KukushkinandGitHub 2f800173a5 Handle exception from iterdir while discovering static files (#3152)
Close https://github.com/patroni/patroni/issues/3151
2024-09-09 15:03:20 +02:00