ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Items 4, 5, 6 and 8 of SERVER-138793. All four are in query_memory_load_shedding.h and query_memory_load_shedding.cpp.

      Double count (item 6). The queued-operation sweep kills an op with killOperation() then recordShed(). The op's own thread, in queryMemoryCheckLoadShedding, calls markKilled() then recordShed() without checking for a pending kill. If both paths hit one op, operationsShed and bytesShed count it twice. The callers run checkForInterrupt() before the shed check, so the sweep's kill has to land between those two calls. The effect is an inflated counter only. Reproduced by a unit test that runs the sweep, then the op-thread check on the killed op, and sees operationsShed = 2 (Item6_SweepThenOpThreadCountsOneOpTwice, attached in a comment). The test forces the order; it does not show that the production window is hit. Fix: return early from the op-thread path when opCtx->isKillPending(), matching the sweep.

      Logging under locks (item 5). sweepQueuedOperationsForMemoryPressure holds ServiceContext::LockedClientsCursor (the clients mutex) and a ClientLock while recordShed formats and writes a log line. Client creation and teardown, and currentOp/killOp on that client, wait behind the log write. At default verbosity at most one line per second is logged at warning severity; the rest are at debug level 2. Confirmed by reading the code, not by a test. Fix: copy the CurOp fields under the lock and log after the loop.

      RSS read under the mutex (item 8). startQueryMemoryRssMonitor calls publishRssSample while holding holder.mutex, and serverStatus takes the same mutex. Measured ProcessInfo::getResidentSize() at p50 18us, p99 23us, max 202us over 2000 reads, so the worst-case serverStatus stall is about 0.2 ms. Fix: take the sample before locking. Optional given the measured cost.

      "Never throws" comment (item 4). query_memory_load_shedding.h:51 says queryMemoryCheckLoadShedding never throws. The first shed registers the OTel counters lazily (mutex and allocation), and the returned Status and the log call also allocate, so std::bad_alloc is possible on this path. The registration itself cannot throw for an ordinary reason: the metric names are constants and no serverStatus path is registered. Decision: keep lazy creation, because eager creation would register four counters on every process where shedding is never enabled. Fix: reword the comment to say the function does not throw on ordinary failures.

      Not in scope: the QueryLifespan slot race (SERVER-139053), and the setParameter races (SERVER-139117).

            Assignee:
            Zixuan Zhuang
            Reporter:
            Zixuan Zhuang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: