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

[DPE-3591] Fix shared buffers validation #361

Merged
merged 12 commits into from
Feb 27, 2024

Conversation

marceloneppel
Copy link
Member

@marceloneppel marceloneppel commented Feb 15, 2024

Issue

The validation for the shared_buffers parameter was not correct. The calculus of the maximum allowed shared buffers value was not correctly converting the available memory for that to the same unit as the shared_buffers parameter that the user informs.

Also, the effective_cache_size parameter did not consider the user-provided shared_buffers value.

One last issue: sometimes, the restart of the PostgreSQL database was not triggered because Patroni hadn't finished reloading the configuration (even after 10 seconds).

Solution

Fix the calculus of the maximum allowed shared buffers value to be in the same unit as the user-provided value.

Considered the user-provided shared buffers value for the effective cache size parameter calculus.

An improved retry mechanism was added to check whether a restart is needed after a configuration change.

Unit tests for the library file are being updated to the K8S charm, which owns the library.

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

codecov bot commented Feb 15, 2024

Codecov Report

Attention: Patch coverage is 67.50000% with 13 lines in your changes are missing coverage. Please review.

Project coverage is 81.25%. Comparing base (41fd24d) to head (a33b39d).
Report is 2 commits behind head on main.

Files Patch % Lines
src/charm.py 67.50% 12 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #361      +/-   ##
==========================================
- Coverage   81.33%   81.25%   -0.08%     
==========================================
  Files          10       10              
  Lines        2207     2235      +28     
  Branches      353      360       +7     
==========================================
+ Hits         1795     1816      +21     
- Misses        343      347       +4     
- Partials       69       72       +3     

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

…e cache size value

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

@taurus-forever taurus-forever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

marceloneppel and others added 7 commits February 17, 2024 12:25
…uffers-validation

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Signed-off-by: Marcelo Henrique Neppel <[email protected]>
…uffers-validation

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
* Reenable landscape tests

* Try GH runners

* Back on self-hosted runner

* Don't check for primary if peer didn't join yet

* Don't recheck missing primary ip when looking for primary endpoint

* Catch list user exception

* Catch Psycopg2 error when trying to set config

* Try to preflight connection on config validation

* Don't retry db connection check

* Set the primary endpoint before starting the primary

* Revert "Set the primary endpoint before starting the primary"

This reverts commit 8184dfa.

* Wait for peer before starting primary

* Switch to GH runners

* Recheck DB connection

* Don't check peer on primary startup

* Try to skip primary IP validation if not all cluster IPs seem to be available

* Comment

* Review comments

* Unit tests
@dragomirp dragomirp merged commit 36e5fa4 into main Feb 27, 2024
43 of 44 checks passed
@dragomirp dragomirp deleted the dpe-3591-fix-shared-buffers-validation branch February 27, 2024 12:37
BON4 pushed a commit to BON4/postgresql-operator that referenced this pull request Apr 23, 2024
* Fix shared buffers validation

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

* Consider shared buffers config option value when calculating effective cache size value

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

* Fix PostgreSQL restart not being called

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

* Add and update unit test

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

* Update unit test

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

* Increase test timeout

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

* Increase test timeout

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

* Switch to GH runners

* Increase stanza timeout

* [MISC] Check for peer relation when getting the primary endpoint (canonical#366)

* Reenable landscape tests

* Try GH runners

* Back on self-hosted runner

* Don't check for primary if peer didn't join yet

* Don't recheck missing primary ip when looking for primary endpoint

* Catch list user exception

* Catch Psycopg2 error when trying to set config

* Try to preflight connection on config validation

* Don't retry db connection check

* Set the primary endpoint before starting the primary

* Revert "Set the primary endpoint before starting the primary"

This reverts commit 8184dfa.

* Wait for peer before starting primary

* Switch to GH runners

* Recheck DB connection

* Don't check peer on primary startup

* Try to skip primary IP validation if not all cluster IPs seem to be available

* Comment

* Review comments

* Unit tests

---------

Signed-off-by: Marcelo Henrique Neppel <[email protected]>
Co-authored-by: Dragomir Penev <[email protected]>
Co-authored-by: Dragomir Penev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants