You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "Sanjay Dutt (Jira)" <ji...@apache.org> on 2024/05/20 09:34:00 UTC
[jira] [Commented] (SOLR-17300) Copy existing listeners on re-creation of Http2SolrClient
[ https://issues.apache.org/jira/browse/SOLR-17300?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17847828#comment-17847828 ]
Sanjay Dutt commented on SOLR-17300:
------------------------------------
There is a possibility of race-condition in the proposed code which could arise in the future or already may have present, not sure yet. Auth listener is never available at the creation of UpdateShardHandler and because of that it never got added to Http2SolrClient in the beginning. Later on, when CoreContainer#reloadSecurityProperties() is called that would call Http2SolrClient#addListenerFatory to add the auth listener.
Below is the code snippet from CoreContainer#loadInternal
{code:java}
826. updateShardHandler = new UpdateShardHandler(cfg.getUpdateShardHandlerConfig());
827. updateShardHandler.initializeMetrics(solrMetricsContext, "updateShardHandler");{code}
And in the same method after few lines, a call to reloadSecurityProperties
{code:java}
875. reloadSecurityProperties();{code}
Now If someone to create the client in-between, or some other case which we cannot think of yet, there will be no auth listener available.
> Copy existing listeners on re-creation of Http2SolrClient
> ---------------------------------------------------------
>
> Key: SOLR-17300
> URL: https://issues.apache.org/jira/browse/SOLR-17300
> Project: Solr
> Issue Type: Sub-task
> Reporter: Sanjay Dutt
> Priority: Major
>
> For custom settings, such as timeouts, usually a Http2SolrClient is created using the existing HTTP client using below code.
> {code:java}
> Http2SolrClient.Builder(leaderBaseUrl)
> .withHttpClient(existingHttp2SolrClient)
> .withIdleTimeout(soTimeout, TimeUnit.MILLISECONDS)
> .withConnectionTimeout(connTimeout, TimeUnit.MILLISECONDS)
> .build();
> {code}
> If not specified, withHttpClient method would automatically copy over some of the older configuration automatically to the new Http2SolrClient
> {code:java}
> if (this.basicAuthAuthorizationStr == null) {
> this.basicAuthAuthorizationStr = http2SolrClient.basicAuthAuthorizationStr;
> }
> if (this.followRedirects == null) {
> this.followRedirects = http2SolrClient.httpClient.isFollowRedirects();
> }
> if (this.idleTimeoutMillis == null) {
> this.idleTimeoutMillis = http2SolrClient.idleTimeoutMillis;
> }
> if (this.requestWriter == null) {
> this.requestWriter = http2SolrClient.requestWriter;
> }
> if (this.requestTimeoutMillis == null) {
> this.requestTimeoutMillis = http2SolrClient.requestTimeoutMillis;
> }
> if (this.responseParser == null) {
> this.responseParser = http2SolrClient.parser;
> }
> if (this.urlParamNames == null) {
> this.urlParamNames = http2SolrClient.urlParamNames;
> }
> {code}
> Nonetheless there is one field that did not pass over yet -- List of HttpListenerFactory. This list also includes the interceptor for Auth due to which re-created client were missing auth credentials and requests were failing.
> *Proposed Solution* :-
> Along with other properties, List of Listener Factory should also be copied over from old to new client using withHttpClient method.
> {code:java}
> if (this.listenerFactory == null) {
> this.listenerFactory = new ArrayList<HttpListenerFactory>();
> http2SolrClient.listenerFactory.forEach(this.listenerFactory::add);
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org