Skip to content

[Bug]: IVF internal SQL loses parent CN pool labels and dispatches TP workload to AP CN #27966

Closed

Description

@LeftHandCold

Description

An IVF/vector-index query submitted through a TP-only account can dispatch its generated internal SQL to an AP CN. This violates the CN label / compute-pool isolation contract and allows a TP workload to consume or depend on AP-pool resources.

This was observed during the TKE 1TP+2AP nightly Family run. The AP CN was also running TPCH 1T and was OOM-killed during TPCH Q10. The available evidence does not prove that IVF caused that OOM: TPCH Q10 was the direct memory-heavy workload at the OOM timestamp. However, the IVF trace independently proves that its internal SQL crossed from the TP pool to that AP CN, and the IVF query failed when that AP CN disappeared.

Environment

Routing evidence

  • TP CN UUID: 31356230-3332-3566-3836-393063663866
  • AP CN UUID: 32656532-3439-3963-3739-326438353331
  • AP CN pod/IP: nightly-regression-dis-ap-cn-2gp42 / 10.143.18.21
  • Client account: tp_tail_index:admin (routed to the TP CN by the outer-query route proof)
  • Trace ID: 68ef8d99-289d-a76e-3082-dbafbcca3f3a

Outer SQL:

SELECT id
FROM ann.items_sift
ORDER BY inner_product(...)
LIMIT 10;

Generated internal SQL included a query against the hidden IVF index table:

SELECT __mo_index_pri_col, inner_product(...)
FROM ann.__mo_index_secondary_...;

The TP CN log then attempted to open a remote scope on the AP CN and failed with:

cannot connect to backend: dial tcp4 10.143.18.21:6002: connect: connection refused

The pod map in the same run confirms that 10.143.18.21 belonged to the AP pool.

Root-cause analysis

The outer frontend compile path preserves the session CN labels:

The vector-index path executes generated SQL through the internal SQL executor:

  • sqlexec.go calls exec.Exec(...) for the nested SQL.

But the internal executor's backSession resets the label map instead of inheriting the upstream session labels:

  • back_exec.go uses backSes.label = make(map[string]string).

As a result, generated internal SQL no longer carries the original TP compute-pool constraint, so distributed scheduling can select an AP CN.

Expected behavior

  • Nested/internal SQL that is part of a user statement must inherit the immutable CN labels / compute-group constraint of the parent statement.
  • Remote scopes for this query must be restricted to TP-compatible CNs.
  • If no compatible TP CN is available, execution should fail closed instead of falling back to an AP CN.
  • Add a regression test with separate TP/AP labels that proves an IVF query's outer and internal SQL never cross pools.

Impact

  • Logical TP/AP resource isolation is not reliable for vector-index queries.
  • TP traffic can contend with AP performance workloads and contaminate performance results.
  • Failure or restart of an unrelated AP CN can break a query issued through a healthy TP CN.

Activity

  1. added
    kind/bug
    on Sep 1, 2026
  2. added
    severity/s0
    and removed on Sep 3, 2026
  3. assigned and unassigned on Sep 9, 2026
  4. slyunnn commented on Sep 10, 2026

    @slyunnn

    Regression and extended verification for #27966 (2026-09-10)

    Verification Environment

    • Scope: 4.2-dev. The original reproduction commit fca65defc18d8df819bce8de3e00663200d7311e is contained in origin/4.2-dev, not origin/main.
    • Verified fixed baseline: 4.2-dev at 4199b11c5c7bb24eccdb379cd6f68abcbd89e450 — [4.2] fix(catalog): correct logical ID index primary column width (#28526).
    • Related fix: PR #28204, merge commit a33d3a1bbbfa507ef1efc7c3748ab70e07d3bcd9, merged into 4.2-dev.
    • Topology: isolated embedded 4 CN cluster with 3 TP / 1 AP CN-label pools. The test uses a real MySQL wire-protocol client and proxy ExtraInfo label preface. Standard shared endpoints Proxy 6001, CN1 16001, and CN2 16002 were not used because they do not expose the required TP/AP label isolation.

    What Was Covered

    • OK — Original IVF route: SELECT id ... ORDER BY l2_distance(...) LIMIT 4 against an IVFFLAT index completed with the TP-labelled client connection.
    • OK — Internal generated SQL against __mo_index_secondary_... was observed and verified to select only TP-compatible CN workers.
    • OK — Happy path covered multi-CN placement, worker cap 2, and a remote TP worker.
    • OK — Unhappy path: after all TP labels were invalidated, nested IVF SQL failed with no candidate CN instead of falling back to an AP CN.
    • OK — Boundary and ownership coverage includes nested compilation, process/remote-pipeline scheduling propagation, batch/streaming/transaction vector-index paths, and cloned label snapshots.
    • OK — TestIssue27966FrontendIVFInternalSQLPreservesQueryPool passed in 15.755s.
    • Not covered — Latest main; this issue was found and fixed on 4.2-dev, while the fix has not yet been merged to main.

    Findings

    PR #28204 preserves the initiating statement's CN-label and scheduling intent through frontend background sessions, process snapshots, remote pipeline serialization, vector-index execution, and nested compilation. The IVF-generated internal SQL therefore remains confined to the TP pool.

    No additional large-data regression is required. The failure depends on labelled multi-CN routing and nested scheduling intent, not row count, block/batch boundaries, memory/spill, skew, network volume, or resource scale. The exercised 3 TP / 1 AP topology is the minimal stable execution boundary.

    MOTR / BVT Coverage

    • No MOTR branch or commit was added: the routing oracle requires observation of internal selected CN workers, which SQL-only MOTR cannot provide.
    • The product regression pkg/tests/issues/issue_27966_test.go is the appropriate end-to-end BVT coverage and passed on 4.2-dev.
    • It runs serially because it changes shared TP/AP labels and relies on ordered invalidation between the outer and nested IVF SQL phases.

    Final Conclusion

    Fixed on 4.2-dev. The original and extended TP/AP routing scenarios pass with the #28204 fix: internal IVF SQL inherits the parent pool constraint and fails closed when no compatible TP CN remains. Large-data regression is not required for this scheduling-state defect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions