Add CollectionAcquirer interface with OnDemand and PreAcquired implementations

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 9.0.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Execution
    • Fully Compatible
    • QE 2026-06-22
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Summary

      Introduce the CollectionAcquirer seam used by the change-stream single-document lookup
      executors to decouple "give me a CollectionAcquisition" from "take a lock". Ships both
      implementations and the point-in-time read guard. No pipeline wiring yet – this is a building
      block consumed by the Express executor (later in this milestone) and reused later by SBE and
      $search.

      Scope

      • Define the CollectionAcquirer abstract interface returning a wrapped
        CollectionAcquisition handle.
      • OnDemandCollectionAcquirer: calls acquireCollectionMaybeLockFree per call. The
        acquirer the Express path uses (target nss varies per event on db/cluster streams).
      • PreAcquiredCollectionAcquirer: locates the upfront AcquiredCollection in
        TransactionResources::acquiredCollections and wraps it with no new lock. {{tassert}}s when
        the requested nss is absent from the upfront list. Propagates exists() == false as the
        authoritative answer at the stream's clusterTime. Ships as the reusable building block for
        $search / SBE; not wired into the pipeline here.
      • assertLocalLookupReadAtOrAfter() snapshot guard: reads the RU point-in-time read timestamp
        and tasserts it is at or after the event's afterClusterTime. No-op for an absent or
        untimestamped read.

      Files

      • src/mongo/db/exec/agg/single_doc_lookup/collection_acquirer.h (header-only)
      • src/mongo/db/exec/agg/single_doc_lookup/BUILD.bazel

      Acceptance criteria

      • Both acquirers implemented behind the common interface; PreAcquired tasserts on a missing nss
        and surfaces exists() == false unchanged.
      • assertLocalLookupReadAtOrAfter() is a no-op for an absent/untimestamped read and tasserts
        otherwise.
      • Unit tests cover: OnDemand acquire, PreAcquired hit / miss-tassert / non-existent-collection,
        and the snapshot guard.

            Assignee:
            Denis Grebennicov
            Reporter:
            Denis Grebennicov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: