Skip to content

[Bug]: IVF vector queries fail with required-current-cn-outside-pool after CN kill despite eligible CNs #27152

Closed

Description

@Ariznawlll

Description

During the 4.2-dev distributed Chaos run, IVF vector queries repeatedly failed after CN kill injection with:

internal error: query schedule cannot satisfy placement, reason required-current-cn-outside-pool, current CN policy required

The scheduler reported two eligible workers in the resolved pool, but rejected the query because the current coordinator CN was outside that pool. This caused the qvec failure rate to increase across consecutive days.

Environment

This report is based on the long-running 4.2-dev Chaos environment. It has not yet been independently reproduced 3/3 on the latest official main.

Steps to reproduce

  1. Deploy a distributed MatrixOne cluster with separate CN pools/labels.
  2. Run the fulltext_vector_test qvec workload using IVF vector queries, for example a query ordered by l2_distance(question_vector, ?).
  3. Inject task_kill_cn against a CN for 30 seconds.
  4. Continue issuing qvec queries during the fault and recovery window.
  5. Inspect qvec results and the CN scheduler warning logs.

Observed timeline from one occurrence:

  • 2026-08-14 14:02:37 CST: task_kill_cn started.
  • 2026-08-14 14:02:46 CST: scheduler emitted required-current-cn-outside-pool.
  • 2026-08-14 14:03:07 CST: Chaos resource cleanup completed.

Actual behavior

The scheduler rejected IVF vector queries even though the resolved pool still contained eligible workers:

reason=required-current-cn-outside-pool
current-cn-policy=required
exec-type=ap-multi-cn
worker-count=0
eligible-worker-count=2
dropped-worker-count=0
requested-pool=tenant:fulltext_vector_test
resolved-pool=shared-unlabeled
pool-fallback=true
worker-set=all
is-internal=false

The failing request was handled by a TP CN, while the requested tenant pool fell back to shared-unlabeled. Since the current CN was not a member of the resolved pool and IVF scheduling required the current CN, no worker was selected.

Impact over the two-day window:

  • First-day incremental qvec failure rate: approximately 6.79%.
  • Second-day incremental qvec failure rate: approximately 11.57%.
  • qvec QPS: 2.2 -> 1.7.
  • qvec average latency: 3.67 s -> 4.83 s.
  • Cumulative required-current-cn-outside-pool errors: 14,425.

Expected behavior

After a CN is killed, an IVF vector query should recover by reconnecting or being routed to a valid CN in the resolved pool. A request must not repeatedly fail solely because its new/current coordinator CN is outside the resolved pool when eligible pool CNs are available.

If IVF correctness requires execution on the current CN, the connection/router should ensure that the current CN is a member of the required pool before accepting or retrying the query.

Stability and controls

  • Reproducer: repeatedly observed in the long-running Chaos run and correlated with task_kill_cn; a standalone 3/3 reproduction has not yet been executed.
  • Control: the nqft workload did not show the same placement error and had approximately 0.16% incremental failures on the second day.
  • A sampled task_network_cn occurrence recovered after cleanup and did not increase the cumulative required-current-cn-outside-pool counter.
  • No data inconsistency was observed in this investigation; the confirmed impact is query failure and throughput degradation.

Evidence

Code analysis

The current code path appears intentional at the individual scheduler decision level:

  1. pkg/sql/compile/scheduler.go forces CurrentCNRequired when an IVF entries internal scan is detected.
  2. pkg/sql/schedule/placement.go returns required-current-cn-outside-pool when the required current CN is not present in the resolved worker pool.

The suspected defect is at the interaction boundary between CN kill recovery, connection routing/pool resolution, and the IVF current-CN requirement. After failover, a qvec session can be accepted by a TP CN that is outside the resolved shared-unlabeled pool, making the query unschedulable despite two eligible pool workers.

The fix should preserve the IVF local-range correctness requirement while ensuring that post-kill routing/reconnection selects a CN belonging to the resolved pool, or otherwise provides a bounded retry/recovery path.

Regression coverage

Add a focused Chaos regression:

  1. Run continuous IVF qvec traffic through the normal service endpoint.
  2. Kill the current CN.
  3. Verify that the replacement connection lands on an eligible pool CN.
  4. Require qvec queries to recover within the defined recovery SLO.
  5. Assert that required-current-cn-outside-pool does not continue after cleanup.
  6. Repeat at least 10 times across CN replacements.

A focused scheduler/router integration test should also cover a required-current IVF request whose post-failover coordinator is outside the resolved pool while other eligible workers exist.

Related

Activity

  1. added this to the MO-202608 milestone on Aug 14, 2026
  2. added
    kind/bug
    on Aug 14, 2026
  3. added theissue type on Aug 14, 2026
  4. self-assigned this
    on Aug 14, 2026
  5. LeftHandCold commented on Aug 14, 2026

    @LeftHandCold
    Collaborator

    已完成针对事故环境、Loki 时间线和当前代码的交叉核验,根因可以收敛,不是 IVF 本身算错,也不是“已有两个 eligible worker 却随机调度失败”。

    结论

    CN 被 kill 后,replacement CN 已经被 Proxy 发现并开始接收新连接,但它自己的本地 MOCluster inventory 还是 replacement 启动前取得的旧快照,快照中没有 replacement 自己。IVF entries 扫描必须把当前协调 CN 放在 worker ordinal 0,因为 appendable IVF ranges 只有当前 CN 能提供;#25990 又把“当前 CN 不在 resolved pool”从隐式补入改成了 fail-closed。因此,在这段启动窗口内,scheduler 必然返回 required-current-cn-outside-pool。

    这是一条确定的启动时序竞态:

    replacement CN process starts
      -> local MOCluster performs initial HAKeeper refresh
      -> refresh succeeds, but snapshot does not contain replacement CN itself
      -> MOCluster marks itself ready
      -> Proxy's independent/fresher cluster view learns replacement CN
      -> Proxy routes qvec connection to replacement CN
      -> IVF scheduler reads replacement CN's stale local inventory
      -> resolved pool is non-empty, but current CN is absent
      -> CurrentCNRequired rejects the query
    

    事故证据

    目标 namespace:mo-chaos-4-2-dev-b83878b-202608110022。

    • 14:02:37.691:pod-kill-cn Chaos 创建。
    • 被替换旧 CN:pod ...-4cfwd,service UUID 36663962-3139-3037-3664-366263643233。
    • 14:02:40.306:replacement CN ...-kk57k 进程启动;新 UUID 63383835-3661-3262-3763-303066633733,pipeline address 10.10.65.151:6002。
    • 14:02:40.829:新 CN heartbeat task 启动。
    • 14:02:44.837/14:02:44.854:新 CN 已收到 CreateTask / JoinGossipCluster。
    • 14:02:46.292:错误第一次出现。日志中的 current UUID/address 正是 replacement CN;eligible-worker-count=2、resolved-pool=shared-unlabeled、dropped-worker-count=0,但 current CN 不在候选快照中。
    • 失败连接来自 Proxy IP 10.10.17.215,证明是 Proxy 新路由到 replacement 的连接,不是旧 CN 残留 session。
    • 错误持续到 14:02:50.839,形成约 4.55 秒的单次启动窗口,之后自动消失,早于 14:03:07.859 Chaos cleanup。
    • 该次 burst 有 373 条真实 SQL 失败;相同 48 小时窗口内识别到 37 次同类 burst,均与 CN replacement 时序吻合。

    部署 CR 实际只有 tp.replicas=2,没有独立 AP pool,也没有显式 CN label;因此 shared-unlabeled fallback 是当前拓扑下的预期结果。Issue 原文“separate CN pools/labels”不是本次触发条件。

    代码闭环

    1. pkg/cnservice/server_heartbeat.go:CN heartbeat 由 ticker 驱动,启动时没有先同步发送一次。
    2. pkg/clusterservice/cluster.go:NewMOCluster.refreshTask 会立即执行首次 refresh;只要 HAKeeper 查询成功,就发布 snapshot 并关闭 ready gate,不检查 snapshot 是否包含本 CN。
    3. Proxy 与 replacement CN 各自维护 cluster view,因此 Proxy 可以先看到 replacement,而 replacement 的本地 view 仍缺自己。
    4. pkg/sql/compile/scheduler.go:IVF entries scan 使用 CurrentCNRequired,并要求当前 CN 位于 ordinal 0。
    5. pkg/sql/schedule/placement.go:required current CN 不在 resolved candidates 时返回 required-current-cn-outside-pool。

    #25990(commit d1aeadeb9d)没有制造 inventory 竞态,但它移除了旧的 ensureCurrentWorker 隐式补入行为,使这个已有启动竞态从潜在错误路由变成了可见 query failure。因此,本次用户可见 availability 回归边界是 #25990,影响 4.2 和 main;4.1/4.0/3.0 没有这条精确报错路径。当前 main 源码仍存在相同启动窗口。

    修复边界

    不应恢复“无条件把 current CN 塞进候选池”,那会破坏 #25990 的 pool 隔离语义;也不应放松 IVF 的 CurrentCNRequired,否则 appendable local ranges 有漏读风险。

    低风险修复应放在 CN 启动入口:在开放 SQL/query ingress 之前,等待本 CN heartbeat 成功,强制刷新本地 authoritative MOCluster,并确认 inventory 已包含本 CN;未满足时 fail closed,不对外提供服务。 这只增加 replacement CN 的启动门槛,不进入正常 query 热路径,也不改变 pool/IVF 调度语义。

    我会按这个边界向 main 提交修复和确定性启动时序回归测试。

  6. added a commit that references this issue on Aug 14, 2026
    91dfe8c
  7. Ariznawlll commented on Aug 20, 2026

    @Ariznawlll
    CollaboratorAuthor

    验证结论

    4.2-dev 当前部署版本为 e9d53c4997e3e022df5aedc3795f16d9739b4aae,已包含修复 PR #27167(commit 04e204c7cb5aa7d1b3cb1b74f8dfea7c858549ca)。

    在 128 Chaos 环境 mo-chaos-4-2-dev-aaac595-202608161347 上核验:修复版本运行超过 18 小时,期间执行了 10 次 pod-kill-cn,两个 CN 日志中 required-current-cn-outside-pool 和 query schedule cannot satisfy placement 均为 0,未发现 panic;故障后 qvec 可继续执行,TPCC 一致性检查持续成功。

    原问题未再复现,测试通过,关闭 issue。

  8. added 3 commits that reference this issue on Sep 17, 2026
    0e3a612
    8f8cc64
    df92d84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s-1

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions