You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2020/05/18 08:37:35 UTC

[GitHub] [kafka] chia7712 opened a new pull request #8685: KAFKA-10014 Always try to close all channels in Selector#close

chia7712 opened a new pull request #8685:
URL: https://github.com/apache/kafka/pull/8685


   https://issues.apache.org/jira/browse/KAFKA-10014
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] chia7712 commented on a change in pull request #8685: KAFKA-10014 Always try to close all channels in Selector#close

Posted by GitBox <gi...@apache.org>.
chia7712 commented on a change in pull request #8685:
URL: https://github.com/apache/kafka/pull/8685#discussion_r427091932



##########
File path: clients/src/main/java/org/apache/kafka/common/network/Selector.java
##########
@@ -363,23 +363,14 @@ public void wakeup() {
     @Override
     public void close() {
         List<String> connections = new ArrayList<>(channels.keySet());
-        try {
-            for (String id : connections)
-                close(id);
-        } finally {
-            // If there is any exception thrown in close(id), we should still be able
-            // to close the remaining objects, especially the sensors because keeping
-            // the sensors may lead to failure to start up the ReplicaFetcherThread if
-            // the old sensors with the same names has not yet been cleaned up.
-            AtomicReference<Throwable> firstException = new AtomicReference<>();
-            Utils.closeQuietly(nioSelector, "nioSelector", firstException);
-            Utils.closeQuietly(sensors, "sensors", firstException);
-            Utils.closeQuietly(channelBuilder, "channelBuilder", firstException);
-            Throwable exception = firstException.get();
-            if (exception instanceof RuntimeException && !(exception instanceof SecurityException)) {
-                throw (RuntimeException) exception;
-            }
-
+        AtomicReference<Throwable> firstException = new AtomicReference<>();

Review comment:
       ```Utils.closeAll``` handle only ```IOException``` and it throws exception instead of keeping exception. Hence, it is not suitable to this case. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] chia7712 closed pull request #8685: KAFKA-10014 Always try to close all channels in Selector#close

Posted by GitBox <gi...@apache.org>.
chia7712 closed pull request #8685:
URL: https://github.com/apache/kafka/pull/8685


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] hachikuji commented on a change in pull request #8685: KAFKA-10014 Always try to close all channels in Selector#close

Posted by GitBox <gi...@apache.org>.
hachikuji commented on a change in pull request #8685:
URL: https://github.com/apache/kafka/pull/8685#discussion_r436403355



##########
File path: clients/src/main/java/org/apache/kafka/common/network/Selector.java
##########
@@ -363,23 +363,14 @@ public void wakeup() {
     @Override
     public void close() {
         List<String> connections = new ArrayList<>(channels.keySet());
-        try {
-            for (String id : connections)
-                close(id);
-        } finally {
-            // If there is any exception thrown in close(id), we should still be able
-            // to close the remaining objects, especially the sensors because keeping
-            // the sensors may lead to failure to start up the ReplicaFetcherThread if
-            // the old sensors with the same names has not yet been cleaned up.
-            AtomicReference<Throwable> firstException = new AtomicReference<>();
-            Utils.closeQuietly(nioSelector, "nioSelector", firstException);
-            Utils.closeQuietly(sensors, "sensors", firstException);
-            Utils.closeQuietly(channelBuilder, "channelBuilder", firstException);
-            Throwable exception = firstException.get();
-            if (exception instanceof RuntimeException && !(exception instanceof SecurityException)) {
-                throw (RuntimeException) exception;
-            }
-
+        AtomicReference<Throwable> firstException = new AtomicReference<>();

Review comment:
       Would it make sense to have a `closeAllQuietly`?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] ijuma commented on a change in pull request #8685: KAFKA-10014 Always try to close all channels in Selector#close

Posted by GitBox <gi...@apache.org>.
ijuma commented on a change in pull request #8685:
URL: https://github.com/apache/kafka/pull/8685#discussion_r426850232



##########
File path: clients/src/main/java/org/apache/kafka/common/network/Selector.java
##########
@@ -363,23 +363,14 @@ public void wakeup() {
     @Override
     public void close() {
         List<String> connections = new ArrayList<>(channels.keySet());
-        try {
-            for (String id : connections)
-                close(id);
-        } finally {
-            // If there is any exception thrown in close(id), we should still be able
-            // to close the remaining objects, especially the sensors because keeping
-            // the sensors may lead to failure to start up the ReplicaFetcherThread if
-            // the old sensors with the same names has not yet been cleaned up.
-            AtomicReference<Throwable> firstException = new AtomicReference<>();
-            Utils.closeQuietly(nioSelector, "nioSelector", firstException);
-            Utils.closeQuietly(sensors, "sensors", firstException);
-            Utils.closeQuietly(channelBuilder, "channelBuilder", firstException);
-            Throwable exception = firstException.get();
-            if (exception instanceof RuntimeException && !(exception instanceof SecurityException)) {
-                throw (RuntimeException) exception;
-            }
-
+        AtomicReference<Throwable> firstException = new AtomicReference<>();

Review comment:
       Have we considered using `Utils.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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] chia7712 commented on pull request #8685: KAFKA-10014 Always try to close all channels in Selector#close

Posted by GitBox <gi...@apache.org>.
chia7712 commented on pull request #8685:
URL: https://github.com/apache/kafka/pull/8685#issuecomment-634167948


   retest this please


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] chia7712 commented on a change in pull request #8685: KAFKA-10014 Always try to close all channels in Selector#close

Posted by GitBox <gi...@apache.org>.
chia7712 commented on a change in pull request #8685:
URL: https://github.com/apache/kafka/pull/8685#discussion_r436445146



##########
File path: clients/src/main/java/org/apache/kafka/common/network/Selector.java
##########
@@ -363,23 +363,14 @@ public void wakeup() {
     @Override
     public void close() {
         List<String> connections = new ArrayList<>(channels.keySet());
-        try {
-            for (String id : connections)
-                close(id);
-        } finally {
-            // If there is any exception thrown in close(id), we should still be able
-            // to close the remaining objects, especially the sensors because keeping
-            // the sensors may lead to failure to start up the ReplicaFetcherThread if
-            // the old sensors with the same names has not yet been cleaned up.
-            AtomicReference<Throwable> firstException = new AtomicReference<>();
-            Utils.closeQuietly(nioSelector, "nioSelector", firstException);
-            Utils.closeQuietly(sensors, "sensors", firstException);
-            Utils.closeQuietly(channelBuilder, "channelBuilder", firstException);
-            Throwable exception = firstException.get();
-            if (exception instanceof RuntimeException && !(exception instanceof SecurityException)) {
-                throw (RuntimeException) exception;
-            }
-
+        AtomicReference<Throwable> firstException = new AtomicReference<>();

Review comment:
       > Would it make sense to have a closeAllQuietly?
   
   copy that




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] hachikuji merged pull request #8685: KAFKA-10014 Always try to close all channels in Selector#close

Posted by GitBox <gi...@apache.org>.
hachikuji merged pull request #8685:
URL: https://github.com/apache/kafka/pull/8685


   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kafka] ijuma commented on a change in pull request #8685: KAFKA-10014 Always try to close all channels in Selector#close

Posted by GitBox <gi...@apache.org>.
ijuma commented on a change in pull request #8685:
URL: https://github.com/apache/kafka/pull/8685#discussion_r426850232



##########
File path: clients/src/main/java/org/apache/kafka/common/network/Selector.java
##########
@@ -363,23 +363,14 @@ public void wakeup() {
     @Override
     public void close() {
         List<String> connections = new ArrayList<>(channels.keySet());
-        try {
-            for (String id : connections)
-                close(id);
-        } finally {
-            // If there is any exception thrown in close(id), we should still be able
-            // to close the remaining objects, especially the sensors because keeping
-            // the sensors may lead to failure to start up the ReplicaFetcherThread if
-            // the old sensors with the same names has not yet been cleaned up.
-            AtomicReference<Throwable> firstException = new AtomicReference<>();
-            Utils.closeQuietly(nioSelector, "nioSelector", firstException);
-            Utils.closeQuietly(sensors, "sensors", firstException);
-            Utils.closeQuietly(channelBuilder, "channelBuilder", firstException);
-            Throwable exception = firstException.get();
-            if (exception instanceof RuntimeException && !(exception instanceof SecurityException)) {
-                throw (RuntimeException) exception;
-            }
-
+        AtomicReference<Throwable> firstException = new AtomicReference<>();

Review comment:
       Have we considered using `Utils.closeAll` instead of multiple `closeQuietly`?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org