Make all instances of internalQuerySpillingMinAvailableDiskSpaceBytes.load() use a consistent internalQuerySpillingMinAvailableDiskSpaceBytes throughout query stages [Query Integration]

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

      Goal / Objective                                                                                          

      Ensure that all QI stages that read internalQuerySpillingMinAvailableDiskSpaceBytes see a consistent, snapshotted value for the full lifetime of a query. The value must be read once (at query initialization or stage construction) and held stable — not re-read from the underlying atomic on each spill or each stage — so that multiple spilling stages within the same query (e.g., two $sort stages, a $group  and a $lookup) all operate against the same threshold.

      Context & Background

       internalQuerySpillingMinAvailableDiskSpaceBytes is an AtomicWord<long long> server parameter (default 500
        MB) that controls the minimum free disk space required before any spilling is permitted. Because it is an atomic, it can be read by calling .load()/.loadRelaxed() anywhere in the codebase. However, calling this way means we don't get a consistent internalQuerySpillingMinAvailableDiskSpaceBytes throughout a query.

      Call sites that should be considered to be updated

        The following query-intergration-owned call sites currently call .load() directly on
        internalQuerySpillingMinAvailableDiskSpaceBytes and must be replaced with the appropriate snapshotted access
         pattern:

        File: src/mongo/db/exec/classic/near.cpp
        Location: FileBasedSorterSpiller construction
        Recommended fix: expCtx->getQueryKnobConfiguration().getInternalQuerySpillingMinAvailableDiskSpaceBytes()

        File: src/mongo/db/exec/classic/text_or.cpp
        Location: Two FileBasedSorterSpiller constructions
        Recommended fix: expCtx()->getQueryKnobConfiguration().getInternalQuerySpillingMinAvailableDiskSpaceBytes()

      Acceptance Criteria

      All QI-owned stages have internalQuerySpillingMinAvailableDiskSpaceBytes see a consistent, snapshotted value for the full lifetime of a query, and to each sorter instance a QI stage constructs.

      Behavioral expectations
        - With default parameter settings, observable behavior of spilling is unchanged.
        - All stages within a single query use the same threshold value, regardless of when their spill operations occur relative to one another.

            Assignee:
            Unassigned
            Reporter:
            Stephanie Eristoff
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: