Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase to v4.0.3 #10

Merged
merged 16 commits into from
Nov 5, 2024
Merged

Rebase to v4.0.3 #10

merged 16 commits into from
Nov 5, 2024

Conversation

alexeyklyukin
Copy link
Member

Rebase to Patroni v4.0.3

UTXOnly and others added 16 commits September 17, 2024 10:06
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`.
- Increase version
- Use newer pyright (not latest)
- Add RNs
…3173)

It is available in PostgreSQL 17

Besides that, enable PG17 in behave tests and include PG17 to supported versions in docs.
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.
)

pgaudit could be added to shared_preload_libraries, but we don't check for it, because setting a custom GUC works in all cases.
Still check against `postgres --describe-config` if a GUC does not have
a validator but is a valid postgres GUC
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.
In the past, Patroni had to update the member key every `loop_wait` interval to prevent its disappearance due to TTL. In Kubernetes, the member key won't disappear, however, Patroni still updates it regularly to propagate current xlog location.

Make those updates configurable. If `kubernetes.xlog_cache_ttl` is set to a positive value and no other member data (i.e. role or timeline) changes, do not update the member pod annotation more frequently than the value of `xlog_cache_ttl` seconds.

This reduces the load on the K8s API, as we don't have to update the pod every loop_wait interval.

If the member needs to be updated due to other reasons (i.e. role change), the xlog position is set to the up-to-date one received from Postgres.

When DEBUG logging is turned on, Patroni will emit log messages similar to the one below when the xlog-only update is withheld because of this parameter:

```
2024-06-06 11:34:36,308 DEBUG: prevented pod update, keeping cached xlog value for up to 10 seconds
```

This parameter is set to 0 by default, so this feature is disabled unless turned on explicitly by the user. The maximum value is 3600s.
Many people have to tune Patroni log level to WARNING, since messages like "no action: I am (patroni1), the leader with the lock" are emitted every HA loop run at an INFO level. Those are noisy and not terribly useful, as Patroni emits a different message anyway when the status quo changes.

This commit changes the default behavior by showing the "no action" message as an INFO for the first time, demoting subsequent repeated "no action" messages to DEBUG.
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 5 committers have signed the CLA.

✅ hughcapet
✅ alexeyklyukin
❌ UTXOnly
❌ CyberDem0n
❌ kviset
You have signed the CLA already but the status is still pending? Let us recheck it.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11678956069

Details

  • 171 of 184 (92.93%) changed or added relevant lines in 22 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.001%) to 99.785%

Changes Missing Coverage Covered Lines Changed/Added Lines %
patroni/main.py 5 6 83.33%
patroni/config.py 3 4 75.0%
patroni/dcs/kubernetes.py 23 34 67.65%
Files with Coverage Reduction New Missed Lines %
patroni/main.py 1 99.03%
Totals Coverage Status
Change from base Build 10898105870: 0.001%
Covered Lines: 14375
Relevant Lines: 14406

💛 - Coveralls

@alexeyklyukin alexeyklyukin merged commit 43cbc4a into master Nov 5, 2024
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants