Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-19225

Async Query Cancellation Not Propagated To RequestThrottler in Java Driver

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Duplicate
    • None
    • Client/java-driver
    • All
    • None

    Description

      Executing a CQL statement asynchronously and then subsequently cancelling it can result in the RequestThrottler becoming "full", as its never informed of the cancellation. 
      CqlRequestHandler does have a callback that handles cancellation, however it doesn't inform the throttler. This is particularly bad when using a throttler such as ConcurrencyLimitingRequestThrottler which tracks the number of in-flight requests as well as queues requests beyond a certain threshold, neither of which gets properly updated when a request is cancelled.

       

      We experienced this issue with java-driver-core 4.17.x, but looking at the code it appears to impact all versions of the Java driver.
       
      To reproduce, one can simply do the following:

      AsyncCqlSession session;
      Statement statement;
      CompletableFuture<AsyncResultSet> future = session.executeAsync(statement).toCompletableFuture();
      future.cancel(true);
      

       
      Doing this repeatedly with a throttler such as ConcurrencyLimitingRequestThrottler you can observe that the throttler is never informed of the cancellation, and eventually it will become saturated with cancelled requests and reject the request. The issue likely applies to any of the methods in AsyncCqlSession, as they all use CqlRequestHandler under the hood.
       
      We fixed the issue in our application by installing a custom CqlRequestHandler that calls signalTimeout on the throttler, and verified that it resolves the problem; adding that logic to the existing callback seems like the most straight forward solution.

      Attachments

        Activity

          People

            Unassigned Unassigned
            kilink Patrick Strawderman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: