SocketError during connection pool check out was not retried, violating retryable reads/writes specification

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Critical - P2
    • 2.22.0
    • Affects Version/s: 2.21.3
    • Component/s: None
    • None
    • 🔵 Done
    • Ruby Drivers
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      Details

      The Ruby driver currently does not retry when a SocketError is raised during connection pool check out. This behavior violates the retryable reads specification (see specification), which since 2022-01-25 requires drivers to retry on handshake network failures.

      Root Cause Analysis

      The issue appears to be in the exception mapping:

      • Socket.getaddrinfo raises Ruby's standard SocketError when DNS resolution fails
      • The map_exceptions method in Address#socket doesn't map SocketError to Mongo::Error::SocketError
      • The retry logic in ReadWorker#modern_read_with_retry only catches Mongo::Error::SocketError and its subclasses
      • As a result, the unmapped SocketError bypasses the retry mechanism entirely

      Suggested fix

      Update the map_exceptions method in Address class to include SocketError in the exception mapping, ensuring it gets converted to Mongo::Error::SocketError so the retry logic can catch and handle it appropriately.

      Code References

            Assignee:
            Dmitry Rybakov
            Reporter:
            Thomas LI
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: