You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by "iamsanjaymalakar (via GitHub)" <gi...@apache.org> on 2026/06/11 03:24:50 UTC
[PR] ZOOKEEPER-5055: Ensure FileTxnLog.close() closes every stream [zookeeper]
iamsanjaymalakar opened a new pull request, #2405:
URL: https://github.com/apache/zookeeper/pull/2405
### 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`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-5055: Ensure FileTxnLog.close() closes every stream [zookeeper]
Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on PR #2405:
URL: https://github.com/apache/zookeeper/pull/2405#issuecomment-5747873699
You will have to rebase to master to see `IOUtils.closeAll`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-5055: Ensure FileTxnLog.close() closes every stream [zookeeper]
Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw merged PR #2405:
URL: https://github.com/apache/zookeeper/pull/2405
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-5055: Ensure FileTxnLog.close() closes every stream [zookeeper]
Posted by "iamsanjaymalakar (via GitHub)" <gi...@apache.org>.
iamsanjaymalakar commented on PR #2405:
URL: https://github.com/apache/zookeeper/pull/2405#issuecomment-5748179273
> Can we reuse newly added `IOUtils.closeAll` ? I think you probably have to add an overload.
Thanks @kezhuw, switched to IOUtils.closeAll with a Collection overload.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-5055: Ensure FileTxnLog.close() closes every stream [zookeeper]
Posted by "iamsanjaymalakar (via GitHub)" <gi...@apache.org>.
iamsanjaymalakar commented on PR #2405:
URL: https://github.com/apache/zookeeper/pull/2405#issuecomment-5373389186
> My Claude said the following is better:) https://gist.github.com/maoling/e5a54f55d7c3c852868713b0e30d4542
@maoling Thanks for the review and the suggestion. I pushed a follow-up commit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-5055: Ensure FileTxnLog.close() closes every stream [zookeeper]
Posted by "iamsanjaymalakar (via GitHub)" <gi...@apache.org>.
iamsanjaymalakar commented on code in PR #2405:
URL: https://github.com/apache/zookeeper/pull/2405#discussion_r4056353099
##########
zookeeper-server/src/main/java/org/apache/zookeeper/common/IOUtils.java:
##########
@@ -71,6 +72,19 @@ public static void closeAll(Closeable... closeables) throws IOException {
}
}
+ /**
+ * Closes every non-null object, preserving any {@link IOException} thrown.
+ *
+ * @param closeables
+ * the objects to close, in iteration order
+ * @throws IOException the first exception thrown while closing, with later
+ * exceptions added as suppressed exceptions
+ * @see #closeAll(Closeable...)
+ */
+ public static void closeAll(Collection<? extends Closeable> closeables) throws IOException {
+ closeAll(closeables.toArray(new Closeable[0]));
Review Comment:
> How about use `Arrays.asList` ? It does no allocation.
Good catch, switched to Arrays.asList. @kezhuw
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-5055: Ensure FileTxnLog.close() closes every stream [zookeeper]
Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on PR #2405:
URL: https://github.com/apache/zookeeper/pull/2405#issuecomment-5747868465
Can we reuse newly added `IOUtils.closeAll` ? I think you probably have to add an overload.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] ZOOKEEPER-5055: Ensure FileTxnLog.close() closes every stream [zookeeper]
Posted by "kezhuw (via GitHub)" <gi...@apache.org>.
kezhuw commented on code in PR #2405:
URL: https://github.com/apache/zookeeper/pull/2405#discussion_r4056331834
##########
zookeeper-server/src/main/java/org/apache/zookeeper/common/IOUtils.java:
##########
@@ -71,6 +72,19 @@ public static void closeAll(Closeable... closeables) throws IOException {
}
}
+ /**
+ * Closes every non-null object, preserving any {@link IOException} thrown.
+ *
+ * @param closeables
+ * the objects to close, in iteration order
+ * @throws IOException the first exception thrown while closing, with later
+ * exceptions added as suppressed exceptions
+ * @see #closeAll(Closeable...)
+ */
+ public static void closeAll(Collection<? extends Closeable> closeables) throws IOException {
+ closeAll(closeables.toArray(new Closeable[0]));
Review Comment:
How about use `Arrays.asList` ? It does no allocation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@zookeeper.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org