Skip to content

ZOOKEEPER-5055: Ensure FileTxnLog.close() closes every stream#2405

Open
iamsanjaymalakar wants to merge 1 commit into
apache:masterfrom
iamsanjaymalakar:ZOOKEEPER-5055-close-all-txn-log-streams
Open

ZOOKEEPER-5055: Ensure FileTxnLog.close() closes every stream#2405
iamsanjaymalakar wants to merge 1 commit into
apache:masterfrom
iamsanjaymalakar:ZOOKEEPER-5055-close-all-txn-log-streams

Conversation

@iamsanjaymalakar

Copy link
Copy Markdown

Problem

org.apache.zookeeper.server.persistence.FileTxnLog.close() returned immediately when closing logStream or an element of streamsToFlush threw java.io.IOException. Streams later in the cleanup sequence were therefore never closed. This can leak file descriptors during log shutdown.

Change

  • Attempt every stream close.
  • Retain the first java.io.IOException.
  • Attach later close failures as suppressed exceptions.
  • Throw the retained exception after cleanup completes.

Testing

  • mvn -pl zookeeper-server -Dtest=FileTxnLogTest test

@maoling maoling left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My Claude said the following is better:)
https://gist.github.com/maoling/e5a54f55d7c3c852868713b0e30d4542

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.

2 participants