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

      The shard-side distinct scan is well covered (YIELD_AUTO executor checks ~every 10ms between docs), but two loops run check-free:

      1. Router-side merge (primary gap) — ClusterDistinctCmd (src/mongo/s/commands/query_cmd/cluster_distinct_cmd.cpp, ~lines 558-600): the file contains zero interrupt checks. After the (interruptible) shard waits, every value from every shard response is inserted into a collated BSONObjSet (collation key generation per insert; up to N x 16MB of values), then the whole set is serialized. Millions of elements = seconds of unkillable router work. Add opCtx->checkForInterrupt(); every 1024 inserts in the per-shard while (it.more()) merge loop and every 1024 appends in the final serialization loop (opCtx is in scope in Invocation::run).
      2. Shard-side per-doc expansion (secondary) — distinct command runner (src/mongo/db/commands/query_cmd/distinct.cpp, ~lines 633-660): the executor loop receives yield-policy interrupt checks between documents, but the loop body expands arrays (extractAllElementsAlongPath) and dedups through a collated BSONElementSet for one document between checks — a document with a very large array is a single check-free span. Add opCtx->checkForInterrupt(); every 4096 elements processed (counter across the command).

            Assignee:
            Kyle Burgess
            Reporter:
            Kyle Burgess
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: