You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/05/10 02:09:50 UTC

[GitHub] [solr] risdenk opened a new pull request, #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

risdenk opened a new pull request, #848:
URL: https://github.com/apache/solr/pull/848

   https://issues.apache.org/jira/browse/SOLR-16190


-- 
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: issues-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk commented on a diff in pull request #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

Posted by GitBox <gi...@apache.org>.
risdenk commented on code in PR #848:
URL: https://github.com/apache/solr/pull/848#discussion_r868763428


##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -241,6 +241,7 @@ private HttpClient createHttpClient(Builder builder) {
     try {
       httpClient.start();
     } catch (Exception e) {
+      close(); // make sure we clean up

Review Comment:
   Make sure we cleanup on a failed start. At least the executor could have been created at this point. Other things might have been created as well.



-- 
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: issues-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk commented on a diff in pull request #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

Posted by GitBox <gi...@apache.org>.
risdenk commented on code in PR #848:
URL: https://github.com/apache/solr/pull/848#discussion_r868761170


##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -250,16 +250,18 @@ private HttpClient createHttpClient(Builder builder) {
   public void close() {
     // we wait for async requests, so far devs don't want to give sugar for this
     asyncTracker.waitForComplete();
-    if (closeClient) {
-      try {
+    try {
+      if (closeClient) {
         httpClient.setStopTimeout(1000);
         httpClient.stop();
-      } catch (Exception e) {
-        throw new RuntimeException("Exception on closing client", e);
+        httpClient.destroy();

Review Comment:
   https://github.com/apache/solr/blob/main/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java#L242 is the only place we call `HttpClient#start()` so we should call stop and destroy when we are done.



-- 
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: issues-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk commented on a diff in pull request #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

Posted by GitBox <gi...@apache.org>.
risdenk commented on code in PR #848:
URL: https://github.com/apache/solr/pull/848#discussion_r868749963


##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -250,16 +250,18 @@ private HttpClient createHttpClient(Builder builder) {
   public void close() {
     // we wait for async requests, so far devs don't want to give sugar for this
     asyncTracker.waitForComplete();
-    if (closeClient) {
-      try {
+    try {
+      if (closeClient) {
         httpClient.setStopTimeout(1000);
         httpClient.stop();
-      } catch (Exception e) {
-        throw new RuntimeException("Exception on closing client", e);
+        httpClient.destroy();

Review Comment:
   I have no idea if `destroy()` is needed, but I was surprised it existed. When I stepped through with the debugger, `destroy` cleaned up more resources which seems to be a good idea on `close()`...



##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -250,16 +250,18 @@ private HttpClient createHttpClient(Builder builder) {
   public void close() {
     // we wait for async requests, so far devs don't want to give sugar for this
     asyncTracker.waitForComplete();
-    if (closeClient) {
-      try {
+    try {
+      if (closeClient) {
         httpClient.setStopTimeout(1000);
         httpClient.stop();
-      } catch (Exception e) {
-        throw new RuntimeException("Exception on closing client", e);
+        httpClient.destroy();
+      }
+    } catch (Exception e) {
+      throw new RuntimeException("Exception on closing client", e);
+    } finally {
+      if (shutdownExecutor) {
+        ExecutorUtil.shutdownNowAndAwaitTermination(executor);
       }

Review Comment:
   Make sure we shutdown the executor even if the close client fails. We want to interrupt the threads since the client is already closed so no need to keep any threads executing.



-- 
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: issues-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] dsmiley commented on a diff in pull request #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

Posted by GitBox <gi...@apache.org>.
dsmiley commented on code in PR #848:
URL: https://github.com/apache/solr/pull/848#discussion_r875305975


##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -250,16 +250,18 @@ private HttpClient createHttpClient(Builder builder) {
   public void close() {
     // we wait for async requests, so far devs don't want to give sugar for this
     asyncTracker.waitForComplete();
-    if (closeClient) {
-      try {
+    try {
+      if (closeClient) {
         httpClient.setStopTimeout(1000);
         httpClient.stop();
-      } catch (Exception e) {
-        throw new RuntimeException("Exception on closing client", e);
+        httpClient.destroy();

Review Comment:
   Makes sense to call destroy to me.



-- 
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: issues-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk merged pull request #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

Posted by GitBox <gi...@apache.org>.
risdenk merged PR #848:
URL: https://github.com/apache/solr/pull/848


-- 
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: issues-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk commented on a diff in pull request #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

Posted by GitBox <gi...@apache.org>.
risdenk commented on code in PR #848:
URL: https://github.com/apache/solr/pull/848#discussion_r868760728


##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -250,16 +250,18 @@ private HttpClient createHttpClient(Builder builder) {
   public void close() {
     // we wait for async requests, so far devs don't want to give sugar for this
     asyncTracker.waitForComplete();
-    if (closeClient) {
-      try {
+    try {
+      if (closeClient) {
         httpClient.setStopTimeout(1000);
         httpClient.stop();
-      } catch (Exception e) {
-        throw new RuntimeException("Exception on closing client", e);
+        httpClient.destroy();

Review Comment:
   https://www.eclipse.org/jetty/javadoc/jetty-9/org/eclipse/jetty/client/HttpClient.html is `Destroyable` (https://www.eclipse.org/jetty/javadoc/jetty-9/org/eclipse/jetty/util/component/Destroyable.html)
   
   > Typically a Destroyable is a [LifeCycle](https://www.eclipse.org/jetty/javadoc/jetty-9/org/eclipse/jetty/util/component/LifeCycle.html) component that can hold onto resources over multiple start/stop cycles. A call to destroy will release all resources and will prevent any further start/stop cycles from being successful.
   
   So I think we actually want to destroy the `httpClient` here since we can't start the `HttpClient` again anyway...



-- 
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: issues-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk commented on a diff in pull request #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

Posted by GitBox <gi...@apache.org>.
risdenk commented on code in PR #848:
URL: https://github.com/apache/solr/pull/848#discussion_r868750031


##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -250,16 +250,18 @@ private HttpClient createHttpClient(Builder builder) {
   public void close() {
     // we wait for async requests, so far devs don't want to give sugar for this
     asyncTracker.waitForComplete();
-    if (closeClient) {
-      try {
+    try {
+      if (closeClient) {
         httpClient.setStopTimeout(1000);
         httpClient.stop();
-      } catch (Exception e) {
-        throw new RuntimeException("Exception on closing client", e);
+        httpClient.destroy();
+      }
+    } catch (Exception e) {
+      throw new RuntimeException("Exception on closing client", e);
+    } finally {
+      if (shutdownExecutor) {
+        ExecutorUtil.shutdownNowAndAwaitTermination(executor);
       }

Review Comment:
   Make sure we shutdown the executor even if the close client fails - do it in the finally block.



##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -250,16 +250,18 @@ private HttpClient createHttpClient(Builder builder) {
   public void close() {
     // we wait for async requests, so far devs don't want to give sugar for this
     asyncTracker.waitForComplete();
-    if (closeClient) {
-      try {
+    try {
+      if (closeClient) {
         httpClient.setStopTimeout(1000);
         httpClient.stop();
-      } catch (Exception e) {
-        throw new RuntimeException("Exception on closing client", e);
+        httpClient.destroy();
+      }
+    } catch (Exception e) {
+      throw new RuntimeException("Exception on closing client", e);
+    } finally {

Review Comment:
   Make sure we shutdown the executor even if the close client fails - do it in the finally block.



-- 
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: issues-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk commented on a diff in pull request #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

Posted by GitBox <gi...@apache.org>.
risdenk commented on code in PR #848:
URL: https://github.com/apache/solr/pull/848#discussion_r868750031


##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -250,16 +250,18 @@ private HttpClient createHttpClient(Builder builder) {
   public void close() {
     // we wait for async requests, so far devs don't want to give sugar for this
     asyncTracker.waitForComplete();
-    if (closeClient) {
-      try {
+    try {
+      if (closeClient) {
         httpClient.setStopTimeout(1000);
         httpClient.stop();
-      } catch (Exception e) {
-        throw new RuntimeException("Exception on closing client", e);
+        httpClient.destroy();
+      }
+    } catch (Exception e) {
+      throw new RuntimeException("Exception on closing client", e);
+    } finally {
+      if (shutdownExecutor) {
+        ExecutorUtil.shutdownNowAndAwaitTermination(executor);
       }

Review Comment:
   Make sure we shutdown the executor even if the close client fails - do it in the finally block.



-- 
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: issues-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


[GitHub] [solr] risdenk commented on pull request #848: SOLR-16190: Http2SolrClient should make sure to shutdown the executor

Posted by GitBox <gi...@apache.org>.
risdenk commented on PR #848:
URL: https://github.com/apache/solr/pull/848#issuecomment-1129104224

   @madrob / @magibney  / @CaoManhDat any thoughts on this?


-- 
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: issues-unsubscribe@solr.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org