Skip to content

SOLR-16190: Http2SolrClient should make sure to shutdown the executor#848

Merged
risdenk merged 3 commits intoapache:mainfrom
risdenk:SOLR-16190
May 18, 2022
Merged

SOLR-16190: Http2SolrClient should make sure to shutdown the executor#848
risdenk merged 3 commits intoapache:mainfrom
risdenk:SOLR-16190

Conversation

@risdenk
Copy link
Contributor

@risdenk risdenk commented May 10, 2022

@risdenk risdenk requested review from CaoManhDat, madrob and magibney May 10, 2022 02:09
@risdenk risdenk self-assigned this May 10, 2022
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense to call destroy to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

try {
httpClient.start();
} catch (Exception e) {
close(); // make sure we clean up
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@risdenk
Copy link
Contributor Author

risdenk commented May 17, 2022

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

Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

+1 looks right. Thanks Kevin.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense to call destroy to me.

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