Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-100052

Uncancelled ConnectionInterface timers can incorrectly extend connection check out

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Networking & Observability
    • ALL

      The implementation of TLConnection::setTimeout captures an anchor to itself which lives for the duration of the timeout. This anchor prevents the handle from being destroyed before the timeout triggers, but it also has the effect of preventing the connection from being returned to the pool or destructed for longer than intended. This can be observed when using ConnectionPool with gRPC sessions, because the implementation of GRPCTransportLayer waits until they've all been destroyed before completing shutdown. It's unclear if this is an issue with singleUseConnections in particular, or if it affects regular ConnectionPool use too.

      https://parsley.mongodb.com/test/mongodb_mongo_master_al2023_arm64_search_with_grpc_search_community_3b522e1d2a5322fb12e7e9eea3f9475be4f5d2d7_25_01_28_15_14_45/0/4b61309bb76c1002daf0cf2583b96690?bookmarks=0,462&selectedLineRange=L387&shareLine=0

      To fix this, we should either change the timeout anchor to be a weak reference, or to be sure to cancel timeouts when attempting to return the connection to the pool.

      In the gRPC case at least, I believe the problematic timer is the refresh timeout timer, which has a default of 1 minute and is set whenever a connection is added to the ready pool.

      https://github.com/10gen/mongo/blob/6e1dbe7ae09a2cfe1391905c63583460a3a853a4/src/mongo/executor/connection_pool.cpp#L1233

            Assignee:
            Unassigned Unassigned
            Reporter:
            patrick.freed@mongodb.com Patrick Freed
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: