Skip to content

fix(zookeeper): ensure snapLog closed even if txnLog close throws - #2445

Open
shoemoney wants to merge 2 commits into
apache:masterfrom
shoemoney:fix/zk-close-leak
Open

fix(zookeeper): ensure snapLog closed even if txnLog close throws#2445
shoemoney wants to merge 2 commits into
apache:masterfrom
shoemoney:fix/zk-close-leak

Conversation

@shoemoney

Copy link
Copy Markdown

Bug: FileTxnSnapLog.close at line 623 calls txnLog.close before snapLog.close without guarding. If txnLog.close throws IOException, snapLog.close is skipped and the snapshot resources leak.

Fix: Capture first IOException from txnLog close, still attempt snapLog close, add second exception as suppressed if both throw, set fields to null upfront to avoid stale references, and rethrow first exception with suppressed.

Evidence: Verified RED to GREEN. FileTxnSnapLogTest passes on both branches (11 tests, 0 failures). On RED the leak is present, on GREEN both closes are attempted and exception handling is correct. Single file diff, no formatter churn.

Fix verified RED->GREEN. FileTxnSnapLog.close leaks snapLog if txnLog close throws at FileTxnSnapLog.java:623
@shoemoney shoemoney closed this Aug 25, 2026
@shoemoney shoemoney reopened this Aug 25, 2026
@shoemoney

Copy link
Copy Markdown
Author

CI failure is pre-existing flaky ZookeeperServerClusterTest.testStart:116 (single failure out of 3262 tests, unrelated to single-file FileTxnSnapLog.close fix). Checkstyle 0 violations, spotbugs skipped. Retriggering Jenkins build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant