[DPE-10780] Configure PostgreSQL workload OOM protection - #1993
Open
oleksii-buhaiov wants to merge 3 commits into
Open
oleksii-buhaiov wants to merge 3 commits into
oleksii-buhaiov wants to merge 3 commits into
Conversation
oleksii-buhaiov
force-pushed
the
feat/dpe-10780-oom-protection
branch
from
September 23, 2026 12:43
790f4e9 to
752b74a
Compare
oleksii-buhaiov
marked this pull request as ready for review
September 23, 2026 19:06
oleksii-buhaiov
requested review from
carlcsaposs-canonical,
dragomirp,
juju-charm-bot,
marceloneppel,
taurus-forever and
xavipg003
and removed request for
a team
September 23, 2026 19:06
dragomirp
reviewed
Sep 23, 2026
Comment on lines
+51
to
+56
| subprocess.check_call([ # noqa: S603 | ||
| "/usr/bin/snap", | ||
| "set", | ||
| "system", | ||
| f"{SNAP_VITALITY_HINT}={updated_hint}", | ||
| ]) |
Contributor
There was a problem hiding this comment.
Can we use the charmlibs-snap to set and get the config?
Author
There was a problem hiding this comment.
looks like we can, will take a look at it
marceloneppel
left a comment
Member
There was a problem hiding this comment.
Great work, @oleksii-buhaiov! I left a comment about one important check.
| logger.error("Unavailable snap architecture %s", platform.machine()) | ||
| raise | ||
| try: | ||
| ensure_snap_oom_protection(charm_refresh.snap_name()) |
Member
There was a problem hiding this comment.
Could you also test whether a refresh from, for example, the charm revision from the 16/stable channel will enable this OOM protection when refreshed to the revision build from this PR's code?
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
DPE-10780: The charm does not configure OOM protection for the PostgreSQL
workload, leaving database availability exposed to process termination
under memory pressure.
Solution
Configure snapd's
resilience.vitality-hintforcharmed-postgresqlbefore snap installation or refresh. Preserve existing entries and their
order, append PostgreSQL only when absent, and verify the configuration
after writing it.
On fresh deployments, snapd starts Patroni with a negative OOM adjustment,
which its PostgreSQL processes inherit. This change does not force a
restart of running services. During a snap-changing refresh, the normal
snap service restart activates the setting.
A charm-only upgrade with an unchanged snap revision does not currently
run this configuration step. Activation for that upgrade path is outside
this change.
Manual validation
Use an amd64 build environment with the repository's build dependencies
installed and a working LXD Juju controller capable of creating VMs.
Use a PR checkout under your home directory that the Juju snap can access.
From the PR checkout:
charmcraftcache pack juju add-model oom-validation juju deploy ./postgresql_ubuntu@24.04-amd64.charm postgresql \ --base ubuntu@24.04 \ --constraints 'arch=amd64 virt-type=virtual-machine cores=2 mem=2G root-disk=16G' \ --config profile=testingWait for the unit to become active and idle, then connect:
juju wait-for unit postgresql/0 --timeout=30m \ --query='workload-status=="active" && agent-status=="idle"' juju ssh postgresql/0Inside the VM:
Expected on this fresh VM: the hint is
charmed-postgresql, systemdreports
OOMScoreAdjust=-899, and Patroni, the PostgreSQL postmaster,and its listed children all show
-899. This value assumes PostgreSQLis the first and only hint entry.
This checks fresh-install configuration and live process adjustments;
it does not test OOM survival or upgrade activation.