ZOOKEEPER-5093: Ensure snapLog closed even if txnLog close throws in FileTxnSnapLog.close - #2445
Conversation
Fix verified RED->GREEN. FileTxnSnapLog.close leaks snapLog if txnLog close throws at FileTxnSnapLog.java:623
|
CI failure is pre-existing flaky |
|
Shall we generalize this ? For example, add |
|
@kezhuw Added All 42 persistence/helper tests pass on JDK 25; SpotBugs, Checkstyle, and Apache RAT pass. The new cleanup regression fails against upstream because snapshot close is skipped, then passes with this change. |
|
Do you have an apache jira account so I can assign ZOOKEEPER-5093 to you ? You may have to request a jira account those days in sign up process. @shoemoney |
|
Merged! Thank you for your contribution! @shoemoney I have assigned ZOOKEEPER-5093 to myself for now. Please ping me your jira id once you have one so I can assign it to you. |
|
Thanks for the merge, @kezhuw. I did not have a Jira account, so I requested one through selfserve.apache.org under the ZooKeeper project with the username shoemoney. It is verified on my side and waiting on PMC review. I will ping you here once it exists so ZOOKEEPER-5093 can be reassigned. |
When transaction-log cleanup throws an IOException, FileTxnSnapLog.close() skips snapshot cleanup and leaves its resources open.
Add IOUtils.closeAll(Closeable...) to attempt every non-null closeable in order, rethrow the first IOException, and attach subsequent exceptions as suppressed. FileTxnSnapLog.close() clears its references and delegates cleanup to the helper. SnapShot now extends Closeable.
Added five helper tests and a persistence regression covering both close failures, suppressed exceptions, and repeated close calls. The regression fails against current upstream FileTxnSnapLog.close() because snapShot.close() is never invoked, and passes with this change.
Validation on JDK 25: all 42 persistence/helper tests passed, with zero SpotBugs findings, zero Checkstyle violations, and a passing Apache RAT license check.
mvn -B -ntp -Pfull-build -pl zookeeper-server -am \ '-Dtest=IOUtilsTest,org.apache.zookeeper.server.persistence.*Test' \ -Dsurefire.failIfNoSpecifiedTests=false -Dsurefire-forkcount=1 \ verify spotbugs:check checkstyle:check mvn -B -ntp -pl zookeeper-server -am apache-rat:check