fix(lifecycle): archive remaining WAL files after shutdown by aglees · Pull Request #10345 · cloudnative-pg/cloudnative-pg
This PR changes 10-29 lines, ignoring generated files.
label
Mar 20, 2026During pod termination (hibernation, rolling update, node drain), PostgreSQL's built-in archiver may be killed before it can archive the final WAL segment. Add a call to ArchiveAllReadyWALs() after each TryShuttingDownSmartFast() in both shutdown paths (context cancellation and SIGTERM signal) to sweep any remaining .ready WAL files via the plugin sidecar, which outlives the postgres container as a native sidecar. A fresh context.Background() is used for the WAL sweep because the parent context may already be cancelled in the context-cancellation path, which would cause gRPC calls to the sidecar to fail immediately. Errors are logged but do not prevent the instance manager from exiting, consistent with existing shutdown error handling. Closes cloudnative-pg#10341 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Andrew Gleeson <Andrew_Gleeson@external.mckinsey.com>
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