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

Cache last updated location for a configurable number of seconds #6

Merged
merged 14 commits into from
Jun 13, 2024

Conversation

alexeyklyukin
Copy link
Member

Instead of updating xlog location in K8s every loop_wait interval,
use a newly introduced parameter "location_cache_ttl" to prevent
location-only updates from happening oftener than the value of
this parameter. It is set to 0 by default, so nothing will change
until it is explicitly set.

Also, the maximum value is set to 10min, to prevent xlog value
to be too stale (although it is only used for monitoring REST endpoints).

Prevent annotation updates when the only update
is the pod xlog location.

This reduces the load on the K8s API for the replicas,
as we don't have to update the pod every loop_wait interval.
Add prevent_xlog_position_only_pod_updates K8s parameter.
Instead of updating xlog location in K8s every loop_wait interval,
use a newly introduced parameter "location_cache_ttl" to prevent
location-only updates from happening oftener than the value of
this parameter. It is set to 0 by default, so nothing will change
until it is explicitly set.

Also, the maximum value is set to 10min, to prevent xlog value
to be too stale (although it is only used for monitoring endpoints).
@coveralls
Copy link

coveralls commented May 29, 2024

Pull Request Test Coverage Report for Build 9485196974

Details

  • 21 of 33 (63.64%) changed or added relevant lines in 4 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.09%) to 99.775%

Changes Missing Coverage Covered Lines Changed/Added Lines %
patroni/config.py 1 2 50.0%
patroni/dcs/kubernetes.py 17 28 60.71%
Totals Coverage Status
Change from base Build 9188970374: -0.09%
Covered Lines: 13772
Relevant Lines: 13803

💛 - Coveralls

Kubernetes DCS is not consistent about config reloads: it sends the DCS-specific
config during init, while global config is sent on reload. Make sure we read
parameters from the kubernetes part of the configuration.

Update xlog_cache_ttl during local configuration reload.
@alexeyklyukin alexeyklyukin marked this pull request as ready for review June 3, 2024 07:34
@alexeyklyukin alexeyklyukin requested review from feikesteenbergen and a team June 3, 2024 07:34
patroni/dcs/kubernetes.py Show resolved Hide resolved
patroni/validator.py Outdated Show resolved Hide resolved
Reflect we are running a fork
Also add XLOG_CACHE_TTL env variable.
We used to rely on cached_xlog_location and replaced_xlog_location when showing a debug message about pod update prevention, but that produced false positives, i.e.
```
2024-06-06 11:34:36,308 DEBUG: prevented pod update, keeping cached xlog value for up to -1 seconds
```

Make sure we only show this message when we actually used cached xlog, no updates happen, but they should have happened,
since cached value and received member value do not match.
Prevents bogus "keeping cahcned xlog value for up to 0 seconds" messages
@alexeyklyukin alexeyklyukin merged commit 4164ebe into master Jun 13, 2024
23 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.

3 participants