Skip to content

Conversation

@mnencia
Copy link
Member

@mnencia mnencia commented Nov 12, 2025

Summary

This PR fixes the memory leak in the plugin-barman-cloud container where memory usage continuously increases on primary instances during WAL archiving.

Motivation

The plugin-barman-cloud container on primary instances was experiencing ever-increasing memory usage due to archived WAL files accumulating in the OS page cache. In Kubernetes environments running on large machines, memory pressure is typically insufficient to naturally evict these cached files, causing them to waste memory that could be used for active workloads.

Changes

After successfully archiving a WAL file, the plugin now explicitly drops it from the OS page cache using fadvise(FADV_DONTNEED). This prevents archived WALs from accumulating in memory and causing the observed memory leak.

Dependencies

This PR depends on cloudnative-pg/barman-cloud#169

Closes #385

@mnencia mnencia changed the title fix(deps): use barman-cloud with fadvise feat: remove wal from cache after archiving Nov 12, 2025
@mnencia mnencia force-pushed the dev/fix-cache-usage branch from 80edf33 to 1e6068b Compare December 1, 2025 14:23
@mnencia mnencia force-pushed the dev/fix-cache-usage branch from 1e6068b to 5a68e1e Compare December 1, 2025 14:36
@mnencia mnencia marked this pull request as ready for review December 1, 2025 14:36
@mnencia mnencia requested a review from a team as a code owner December 1, 2025 14:36
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Dec 1, 2025
armru
armru previously approved these changes Dec 2, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Dec 2, 2025
@leonardoce leonardoce merged commit df22bf2 into main Dec 3, 2025
8 checks passed
@leonardoce leonardoce deleted the dev/fix-cache-usage branch December 3, 2025 10:38
renovate bot added a commit to sdwilsh/ansible-playbooks that referenced this pull request Jan 8, 2026
…v0.10.0

##### [\`v0.10.0\`](https://github.com/cloudnative-pg/plugin-barman-cloud/releases/tag/v0.10.0)

##### Features

- Add `pprof-server` support  ([#538](cloudnative-pg/plugin-barman-cloud#538)) ([921b20c](cloudnative-pg/plugin-barman-cloud@921b20c)), closes [#421](cloudnative-pg/plugin-barman-cloud#421)
- Remove wal from cache after archiving ([#659](cloudnative-pg/plugin-barman-cloud#659)) ([df22bf2](cloudnative-pg/plugin-barman-cloud@df22bf2))

##### Bug Fixes

- **deps:** Update all non-major go dependencies ([#685](cloudnative-pg/plugin-barman-cloud#685)) ([df2f91d](cloudnative-pg/plugin-barman-cloud@df2f91d))
- **deps:** Update all non-major go dependencies ([#701](cloudnative-pg/plugin-barman-cloud#701)) ([db96dcc](cloudnative-pg/plugin-barman-cloud@db96dcc))
- **deps:** Update k8s.io/utils digest to [`383b50a`](cloudnative-pg/plugin-barman-cloud@383b50a) ([#695](cloudnative-pg/plugin-barman-cloud#695)) ([95ef5dc](cloudnative-pg/plugin-barman-cloud@95ef5dc))
- **deps:** Update k8s.io/utils digest to [`9d40a56`](cloudnative-pg/plugin-barman-cloud@9d40a56) ([#684](cloudnative-pg/plugin-barman-cloud#684)) ([0ea3d91](cloudnative-pg/plugin-barman-cloud@0ea3d91))
- **deps:** Update kubernetes packages to v0.35.0 ([#694](cloudnative-pg/plugin-barman-cloud#694)) ([30dbc44](cloudnative-pg/plugin-barman-cloud@30dbc44))
- **deps:** Update module google.golang.org/grpc to v1.78.0 ([#697](cloudnative-pg/plugin-barman-cloud#697)) ([3f8d4f7](cloudnative-pg/plugin-barman-cloud@3f8d4f7))
- **deps:** Update module sigs.k8s.io/kustomize/api to v0.21.0 ([#651](cloudnative-pg/plugin-barman-cloud#651)) ([ef19031](cloudnative-pg/plugin-barman-cloud@ef19031))
- Don't log full environment variables at default log level ([#589](cloudnative-pg/plugin-barman-cloud#589)) ([a487c4e](cloudnative-pg/plugin-barman-cloud@a487c4e))
- **targetTime:** Treat RFC3339-like timestamps without timezone as UTC ([#700](cloudnative-pg/plugin-barman-cloud#700)) ([1f1d300](cloudnative-pg/plugin-barman-cloud@1f1d300)), closes [#699](cloudnative-pg/plugin-barman-cloud#699)
sdwilsh pushed a commit to sdwilsh/ansible-playbooks that referenced this pull request Jan 8, 2026
…v0.10.0

##### [\`v0.10.0\`](https://github.com/cloudnative-pg/plugin-barman-cloud/releases/tag/v0.10.0)

##### Features

- Add `pprof-server` support  ([#538](cloudnative-pg/plugin-barman-cloud#538)) ([921b20c](cloudnative-pg/plugin-barman-cloud@921b20c)), closes [#421](cloudnative-pg/plugin-barman-cloud#421)
- Remove wal from cache after archiving ([#659](cloudnative-pg/plugin-barman-cloud#659)) ([df22bf2](cloudnative-pg/plugin-barman-cloud@df22bf2))

##### Bug Fixes

- **deps:** Update all non-major go dependencies ([#685](cloudnative-pg/plugin-barman-cloud#685)) ([df2f91d](cloudnative-pg/plugin-barman-cloud@df2f91d))
- **deps:** Update all non-major go dependencies ([#701](cloudnative-pg/plugin-barman-cloud#701)) ([db96dcc](cloudnative-pg/plugin-barman-cloud@db96dcc))
- **deps:** Update k8s.io/utils digest to [`383b50a`](cloudnative-pg/plugin-barman-cloud@383b50a) ([#695](cloudnative-pg/plugin-barman-cloud#695)) ([95ef5dc](cloudnative-pg/plugin-barman-cloud@95ef5dc))
- **deps:** Update k8s.io/utils digest to [`9d40a56`](cloudnative-pg/plugin-barman-cloud@9d40a56) ([#684](cloudnative-pg/plugin-barman-cloud#684)) ([0ea3d91](cloudnative-pg/plugin-barman-cloud@0ea3d91))
- **deps:** Update kubernetes packages to v0.35.0 ([#694](cloudnative-pg/plugin-barman-cloud#694)) ([30dbc44](cloudnative-pg/plugin-barman-cloud@30dbc44))
- **deps:** Update module google.golang.org/grpc to v1.78.0 ([#697](cloudnative-pg/plugin-barman-cloud#697)) ([3f8d4f7](cloudnative-pg/plugin-barman-cloud@3f8d4f7))
- **deps:** Update module sigs.k8s.io/kustomize/api to v0.21.0 ([#651](cloudnative-pg/plugin-barman-cloud#651)) ([ef19031](cloudnative-pg/plugin-barman-cloud@ef19031))
- Don't log full environment variables at default log level ([#589](cloudnative-pg/plugin-barman-cloud#589)) ([a487c4e](cloudnative-pg/plugin-barman-cloud@a487c4e))
- **targetTime:** Treat RFC3339-like timestamps without timezone as UTC ([#700](cloudnative-pg/plugin-barman-cloud#700)) ([1f1d300](cloudnative-pg/plugin-barman-cloud@1f1d300)), closes [#699](cloudnative-pg/plugin-barman-cloud#699)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ever-increasing memory usage (memory leak?)

3 participants