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

Always release `opCtx` before cleaning up session

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Internal Code
    • Labels:
    • Service Arch
    • ALL
    • Service Arch 2023-08-21, Service Arch 2023-09-04
    • 20

      An operation-fatal error that kills the opCtx (e.g., a connection failure) while running an exhaust operation can result in creating a new opCtx to cleanup exhaust resources, while the old one is still attached to the client. This triggers a tassert and terminates the connection thread before it can clean up exhaust resources. Consider the following:

      • handleRequest notices that the connections is closed, so kills the operation and returns a ConnectionError.
      • This translates to calling _onLoopError from here, while the original opCtx associated with WorkItem is still in scope.
      • _onLoopError calls into _cleanupSession, which tries to delist the operation but is not successful in this case since it's already killed due to the connection error.
      • Next, the thread will call into _cleanupExhaustResources, which attempts to make a new opCtx in order to run killExhaust.

      A possible fix is to always destroy the opCtx as part of running _cleanupSession.

            jason.chan@mongodb.com Jason Chan
            amirsaman.memaripour@mongodb.com Amirsaman Memaripour
            0 Vote for this issue
            3 Start watching this issue