Skip to content

[Design]: align ExpressionExecutor retained capacity with HashBuild budget lifetime #26433

Closed

Description

@XuPeng-SH

Context

Follow-up from #26408 and #26412. #26412 closes spill-payload ownership and several concrete cleanup leaks, but expression executors can retain reusable vectors/capacity outside the lifetime currently represented by HashBuild memory reservations.

Problem

Budget accounting must describe memory that remains physically retained, not only the logical rows or batches currently being processed. If an ExpressionExecutor keeps vector capacity across calls, resets, or execution generations while the corresponding HashBuild reservation is released or recomputed independently, admission can undercount memory and later growth can exceed the intended query envelope.

The inverse error is also possible: charging retained capacity twice after reuse can reject work unnecessarily.

Proposed direction

  • Give retained executor buffers an explicit owner and generation.
  • Couple reservation acquisition, resize, reuse, reset, and release to the actual retained capacity lifetime.
  • Define transfer rules when executor results/vectors are borrowed or moved into another operator.
  • Expose retained versus active bytes in diagnostics without double counting shared memory.

Acceptance criteria

  • Capped-budget tests cover initial allocation, growth, reuse, Reset, Free, cancellation, expression failure, and repeated execution generations.
  • Accounted bytes track retained vector capacity within a documented bounded delta.
  • Cleanup returns both mpool usage and budget reservations to baseline exactly once.
  • Reuse does not double-charge existing capacity and cannot consume unreserved growth.
  • Tests include HashJoin, DedupJoin, and RightDedupJoin expression-key paths.

Related: #26408, #26412, and the broader resource envelope in #25782.

Activity

  1. added
    severity/s0
    on Jul 30, 2026
  2. assigned and unassigned on Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/designseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions