Skip to content

Conversation

@jvanneman
Copy link

@jvanneman jvanneman commented Dec 30, 2025

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

Description

PR 2402 added support for CompletableFuture which accidentally introduced a double registration bug in HttpJettySolrClient by calling onRequestQueued/onComplete twice with asyncListener.queuedListener/completeListener. The registration is added once in the makeRequest helper inside of decorateRequest:

    if (isAsync) {
      req.onRequestQueued(asyncTracker.queuedListener);
      req.onComplete(asyncTracker.completeListener);
    }

and a second time below that during the following sequence:

    mrrv.request
        .onRequestQueued(asyncTracker.queuedListener)
        .onComplete(asyncTracker.completeListener)

This introduces three undesirable scenarios: 

  1. Potential deadlock due to a surge in requests that all acquire 1 permit and cannot acquire a second
  2. Unnecessary system throttling when a request acquires a single permit but can't acquire a second due to in flight requests and new requests that arrived after the first token acquisition but before the second.
  3. Half the number of permits available

Solution

Remove the duplicate registration.

Tests

This is a difficult bug to reproduce in a test. One option that I tested and works is to expose the permits as a configurable value via system properties and make this an instance level configuration. If that's something we'd want to do it's straightforward to write a test that sets this value with the builderwithMaxAsyncRequests(1) and causes a deadlock.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended, not available for branches on forks living under an organisation)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide
  • I have added a changelog entry for my change

…uced a double registration bug in HttpJettySolrClient by calling onRequestQueued/onComplete twice with asyncListener.queuedListener/completeListener

This introduces three undesirable scenarios:

Potential deadlock due to a surge in requests that all acquire 1 permit and cannot acquire a second
 Unnecessary system throttling when a request acquires a single permit but can't acquire a second due to in flight requests and new requests that arrived after the first token acquisition but before the second.
Half the number of permits available
@jvanneman jvanneman force-pushed the SOLR-18051-fix-double-registration-bug branch from 13299a5 to 12f24da Compare December 30, 2025 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant