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

Handle SBE plans with slots or stages string not fitting into internalQueryExplainSizeThresholdBytes

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • ALL
    • Hide

      See repro.js

      Show
      See repro.js
    • QE 2024-12-23
    • 0

      Currently if we try to explain an SBE plan with huge slots value.
      For example, db.coll.find({a: {$in: 16 MB of strings} with an index on

      {a: 1}

      will an array of index bounds that will take ~32 MB (because every strings in $in will generate left and right ends of an interval).

      And in explain output they will be added to BSONObjBuilder as a single string:
      https://github.com/mongodb/mongo/blob/17b674eac96c953bd40d3c42854c82a4e8668d50/src/mongo/db/query/plan_explainer_sbe.h#L88

      This maybe considered reasonable behavior, because such query is unreasonable,

      However, it may hinder some error handling and hide errors.
      For example, here we try to get basic explain data for an error log and it will throw an error instead of an actual error. And this can happen in execution, not explain:
      https://github.com/mongodb/mongo/blob/17b674eac96c953bd40d3c42854c82a4e8668d50/src/mongo/db/commands/query_cmd/run_aggregate.cpp#L394

      It may even happen when aggregation throws a retryable error like "QueryPlanKilled" due to collection drop and it will change into a non-retryable one.

            Assignee:
            ivan.fefer@mongodb.com Ivan Fefer
            Reporter:
            ivan.fefer@mongodb.com Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: