Skip to content

Commit 8937882

Browse files
committed
docs: explain rationale for fadvise in container context
Signed-off-by: Marco Nenciarini <[email protected]>
1 parent 9090a86 commit 8937882

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/walarchive/cmd.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,12 @@ func (archiver *BarmanArchiver) CheckWalArchiveDestination(ctx context.Context,
193193
return nil
194194
}
195195

196-
// fadviseNotUsed issues an fadvise to the OS to inform that the file is not needed anymore
196+
// fadviseNotUsed issues an fadvise to the OS to inform that the file is not needed anymore.
197+
// This is necessary because we run in a separate container from PostgreSQL in Kubernetes.
198+
// Without this hint, archived WALs accumulate in page cache since memory pressure on large
199+
// machines is typically insufficient to evict them, wasting memory that could be used for
200+
// active workloads. PostgreSQL handles its own cache management, but our archiver sidecar
201+
// needs to do the same for the files it processes.
197202
func (archiver *BarmanArchiver) fadviseNotUsed(fileName string) (err error) {
198203
file, err := os.Open(filepath.Clean(fileName))
199204
if err != nil {

0 commit comments

Comments
 (0)