Skip to content

[Task]: Retire the legacy UPDATE planner and converge on MULTI_UPDATE #26336

Closed
8 of 8 issues completed
Closed

Description

@XuPeng-SH

Background

MatrixOne currently has two general UPDATE planning paths:

  • the modern bindUpdate path, which produces MULTI_UPDATE;
  • the legacy buildTableUpdate path, selected when bindAndOptimizeUpdateQuery catches almost any ErrUnsupportedDML.

On current main, this is a broad catch-all rather than a typed planner decision. For example, ResolveUpdateTables calls ResolveTables(..., respectFKCheck=false), so any target carrying Fkeys or RefChildTbls falls back even when the UPDATE changes no FK-related column and even when foreign_key_checks=0.

This fallback is production-reachable. A real-server reproduction on current main showed that adding FK metadata changes the same nullable-UNIQUE UPDATE from a successful MULTI_UPDATE plan to the legacy PreInsert UniqueKey plan, where #26334 causes a false duplicate-key error.

Maintaining two independent UPDATE DAG builders also multiplies correctness work for generated columns, assignment casts, joined-row deduplication, locking, FK actions, and index maintenance.

Goal

Converge supported UPDATEs on the modern MULTI_UPDATE architecture. Each UPDATE must have one explicit disposition:

  1. modern MULTI_UPDATE;
  2. a named specialized planner where the storage model requires one (currently Iceberg row-level DML); or
  3. an explicit user-facing rejection before locks or mutations.

The end state has no generic ErrUnsupportedDML -> buildTableUpdate routing.

Scope

  • Fix [Bug]: nullable index UPDATE keeps Rowid from filtered NULL row #26334 immediately so the reachable legacy path is safe during migration.
  • Inventory and instrument every current legacy UPDATE route.
  • Select the route from statement/table capabilities and the columns actually updated, not from broad metadata presence.
  • Port FK validation/actions, multi-target UPDATE, synchronous irregular-index maintenance, and supported special cases.
  • Preserve atomicity, locking, affected-row, generated-column, partition, and hidden-index semantics.
  • Remove only UPDATE-specific legacy code after call-graph proof that it is unreachable.

Non-goals

  • Removing INSERT, DELETE, LOAD, REPLACE, FK, or index utilities that remain independently reachable.
  • Forcing unsupported storage/table forms through MULTI_UPDATE.
  • Changing SQL compatibility or weakening FK/index validation as part of the planner migration.

Work breakdown

Recommended order and dependencies:

Acceptance criteria

  • bindAndOptimizeUpdateQuery has no generic fallback to buildTableUpdate.
  • Every previously reachable route is covered by an executable plan test and resolves to MULTI_UPDATE, a named specialized planner, or an explicit pre-mutation error.
  • FK handling is column-sensitive and preserves the defined foreign_key_checks behavior.
  • FK RESTRICT/NO ACTION, CASCADE, SET NULL, self-reference, and recursive cases are atomic and maintain affected indexes.
  • Multi-target UPDATE preserves per-target Rowid filtering/deduplication, final-row-image semantics, lock order, and affected-row behavior.
  • Synchronous FULLTEXT/IVF maintenance is correct; async algorithms keep their CDC contract; unsafe synchronous-index PK updates remain rejected.
  • Telemetry reports zero legacy UPDATE executions for the agreed regression/soak window.
  • Shared DML operators/utilities are retained unless independent call-graph analysis proves they are dead.
  • Targeted planner/colexec tests and distributed UPDATE/FK/index suites pass in the required transaction modes.

Rollout guardrails

  1. Land [Bug]: nullable index UPDATE keeps Rowid from filtered NULL row #26334 and route observability first.
  2. Replace one explicitly classified route at a time.
  3. Keep compatibility tests for both successful behavior and exact rejection behavior.
  4. Remove the legacy path only after every classified reason is closed and telemetry shows no unexplained use.

Sub-issues

Sub-issues

8 of 8 Issues completed
Loading 8 sub-issues

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions