ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: 8.3.11, 7.0.45
    • Component/s: None
    • None
    • ALL
    • Hide

      1. Start two standalone mongod 7.0.45 instances, one with --tlsMode requireTLS
      and one without TLS. Insert about 60 documents into a collection on each.
      2. From a Go client (go.mongodb.org/mongo-driver/v2 v2.8.0), run an aggregate
      that takes a few seconds, for example
      *[{$match: {$expr: {$function: {body: "function()

      { sleep(100); return true; }

      ", args: [], lang: "js"}}}}].*
      Use a 300 ms context deadline so the client times out and closes the
      connection. The v2 driver sends no maxTimeMS on aggregate, so only
      kill-on-disconnect can stop the operation.
      3. Watch the operation with $currentOp and the slow query log.

      *Actual:*

      • Over TLS, the aggregate keeps running and completes normally after about 6 s.
        There is no ClientDisconnect and no log id 20883 for its connection.
      • The same test on 8.3.11 over TLS behaves the same.

      *Expected:* the operation is killed with ClientDisconnect shortly after the
      client closes, as it is:

      • without TLS (killed after about 1 s, log id 20883);
      • over TLS with pymongo 4.11 (killed after about 0.5 s).
      Show
      1. Start two standalone mongod 7.0.45 instances, one with --tlsMode requireTLS and one without TLS. Insert about 60 documents into a collection on each. 2. From a Go client ( go.mongodb.org/mongo-driver/v2 v2.8.0), run an aggregate that takes a few seconds, for example *[{$match: {$expr: {$function: {body: "function() { sleep(100); return true; } ", args: [], lang: "js"}}}}].* Use a 300 ms context deadline so the client times out and closes the connection. The v2 driver sends no maxTimeMS on  aggregate , so only kill-on-disconnect can stop the operation. 3. Watch the operation with $currentOp and the slow query log. * Actual: * Over TLS, the aggregate keeps running and completes normally after about 6 s. There is no  ClientDisconnect  and no log id 20883 for its connection. The same test on 8.3.11 over TLS behaves the same. * Expected: * the operation is killed with  ClientDisconnect  shortly after the client closes, as it is: without TLS (killed after about 1 s, log id 20883); over TLS with pymongo 4.11 (killed after about 0.5 s).
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      aggregate opts into kill-on-disconnect (handleMarkKillOnClientDisconnect),
      and over plain TCP an aggregate whose client has disconnected is killed with
      ClientDisconnect within about a second. Over TLS, if the client closes cleanly
      (sends a `close_notify` alert, then closes the socket), the operation is never
      detected as disconnected and runs to completion. The Go driver always closes
      this way, because Go's crypto/tls sends close_notify on Close().

      The likely cause is in
      [{*}AsioSession::isConnected(){*}](https://github.com/mongodb/mongo/blob/r7.0.14/src/mongo/transport/asio/asio_session_impl.cpp).
      It treats a socket as connected if one byte can be peeked, so the unread
      close_notify record sitting before the FIN makes a closed peer look connected.

      On Atlas (7.0.45, TLS) this left aggregates from timed-out Go clients running on
      secondaries for 31 and 60 minutes, and client retries piled up more of them.

            Assignee:
            Chris Kelly
            Reporter:
            SR N/A (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: