Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5451

Ensure no race condition in retries for server selection timeouts

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Java Drivers
    • Not Needed

      A possible race condition occurs in RetryState when MongoOperationTimeout is triggered during server selection. For instance, if the server selection timeout is set to 2 ms and the overall timeout (timeoutMS) is 100 ms, a MongoOperationTimeoutException might be thrown due to the server selection timeout expiring. However, since the overall timeout still has milliseconds remaining, RetryState may incorrectly handle the retry logic. This results in the previous attempt's exception being thrown as is, without being correctly wrapped in a MongoOperationTimeoutException.

      Expected Behavior: The retry logic should recognize that a MongoOperationTimeoutException has been triggered outside the RetryState and correctly wrap the previous attempt exception in MongoOperationTimeoutException.

      Actual Behavior: The retry logic fails to correctly wrap the previous attempt exception in a MongoOperationTimeoutException due to the remaining time in timeoutMS.

            Assignee:
            slav.babanin@mongodb.com Slav Babanin
            Reporter:
            slav.babanin@mongodb.com Slav Babanin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: