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: Fixed
    • Priority: Icon: Unknown Unknown
    • 5.2.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Java Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      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:
              Resolved: