Skip to content

Conversation

marceloneppel
Copy link
Member

The previous is_restart_pending() waited for long due to the Patroni's loop_wait default value (10 seconds), which tells how much time Patroni will wait before checking the configuration file again to reload it.

Instead of checking PostgreSQL pending_restart from pg_settings, let's check Patroni API pending_restart=True flag.

Issue

Solution

Checklist

  • I have added or updated any relevant documentation.
  • I have cleaned any remaining cloud resources from my accounts.

The previous is_restart_pending() waited for long due to the Patroni's
loop_wait default value (10 seconds), which tells how much time
Patroni will wait before checking the configuration file again to reload it.

Instead of checking PostgreSQL pending_restart from pg_settings,
let's check Patroni API pending_restart=True flag.

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 46.66667% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.66%. Comparing base (3346862) to head (9e3c353).

Files with missing lines Patch % Lines
src/patroni.py 33.33% 8 Missing ⚠️

❌ Your project check has failed because the head coverage (67.66%) is below the target coverage (70.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           16/edge    #1095      +/-   ##
===========================================
- Coverage    67.81%   67.66%   -0.15%     
===========================================
  Files           15       15              
  Lines         4129     4135       +6     
  Branches       606      604       -2     
===========================================
- Hits          2800     2798       -2     
- Misses        1106     1114       +8     
  Partials       223      223              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@marceloneppel marceloneppel added the not bug or enhancement PR is not 'bug' or 'enhancement'. For release notes label Sep 9, 2025
The current Patroni 3.2.2 has wired/flickering  behaviour:
it temporarily flag pending_restart=True on many changes to REST API,
which is gone within a second but long enough to be caught by charm.
Sleepping a bit is a necessary evil, until Patroni 3.3.0 upgrade.

The previous code sleept for 15 seconds waiting for pg_settings update.

Also, the unnecessary restarts could be triggered by missmatch of
Patroni config file and in-memory changes coming from REST API,
e.g. the slots were undefined in yaml file but set as an empty JSON {} => None.
Updating the default template to match the default API PATCHes and avoid restarts.

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Libraries: Out of sync not bug or enhancement PR is not 'bug' or 'enhancement'. For release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant