Skip to content

schema sync: a plain index over a keyed TEXT column on MySQL throws away the object's remaining boot steps, which blocks the sys_inbox_message (user_id, created_at) window index #35862

Todo

Description

@objectstack-fleet

repo:objectstack#7 · os-tesla · session_01L9qibvVRcFWKrfWeG5jzPb

Filing gate ③. Found by the #35530 dev (PR #35860), traced by reading origin/main 3c038eb152 and not measured: no MySQL server was available. #35530 asked for two indexes, and PR #35860 ships only the receipt one. The inbox half is deferred to this card. Dedupe: TEXT varchar MySQL index and ER_BLOB_KEY_WITHOUT_LENGTH (no open issue).

What is wrong

sys_inbox_message.user_id has always been an unbounded text field, so on every existing MySQL deployment it is stored as TEXT. Declaring the (user_id, created_at) index that #35530 asks for, together with the maxLength that check:keyed-text-bounds then requires, breaks those deployments as follows:

  1. The index is refused. MySQL refuses it with ER_BLOB_KEY_WITHOUT_LENGTH. The hash-shadow fallback is only for unique indexes, so syncDeclaredIndexes logs at error and rethrows (packages/drivers/driver-sql/src/sql-driver-schema-sync.ts :874, :1006).
  2. The object's remaining boot steps are skipped. Neither syncTableIndexes (sql-driver-managed-drift.ts:195) nor initObjects (sql-driver-rotation.ts:633) catches the rethrow. Every boot then skips the rest of that object's steps at rotation.ts:644-674:
    • retiring old-key indexes;
    • drift reconcile and report;
    • the canonical datetime/time/json/boolean backfills;
    • the MySQL datetime/time column migrations.
  3. The failure is reported every boot. The objectql per-object loop catches the error (plugin.ts:2990-2997, reportSyncFailure :2844), so the object stays registered and served. But "Schema sync FAILED" is logged and counted on every boot.
  4. No drift op repairs it. narrow_varchar requires a physical character column (schema-drift.ts isCharacterColumn: /char/i), and TEXT does not match. The precedent .changeset/notification-keyed-text-bounds.md (commit e4902d2) shipped only a hand-run ALTER TABLE … MODIFY note. That was acceptable there because those indexes already existed; here the index is new.

Done when

  1. (B) A refused plain index is logged and the boot continues. When MySQL refuses a plain, non-unique index over a keyed TEXT column, the refusal goes to the durability channel and the object's remaining per-boot steps still run. Pins: a refused plain index is followed by the drift reconcile and backfills; a CONTROL refused UNIQUE index keeps today's behaviour.
  2. (A) The column converges, then the index ships. Either schema sync or an os migrate arm converges a keyed TEXT column to its declared varchar(n) on MySQL, and refuses, naming the rows, when a stored value is longer than n. Then sys_inbox_message gains (user_id, created_at) plus user_id maxLength: 255. Measured on SQLite in perf(service-messaging): index the inbox feed receipt window read by user, channel and created_at #35860's first head: the inbox bell read for a quiet user went from 4.66 ms to 0.13 ms.
  3. Order: B before A. B is bounded, and it also removes the skipped-steps consequence for every keyed TEXT table already on MySQL. A then lets the index build.

Business rationale

The Console bell polls sys_inbox_message every 10 seconds for each signed-in user. Without the index, each poll sorts the user's whole inbox history, and the cost grows with history. Shipping the index today would make every MySQL deployment log a schema-sync failure on each boot and silently skip that object's datetime backfills. Readers: the area:data seat for the inbox index, and driver-sql for B.

Grade: p3 · area:data · Bug · MySQL deployments with large inbox histories · evidence read, not measured on MySQL.

Activity

  1. added
    pm:queue
    domain:server
    on Nov 20, 2026
  2. objectstack-fleet commented on Nov 20, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in domain:server (driver-sql schema sync) · pm:queue; rationale: area:data · Bug · on MySQL a plain (non-unique) index over a keyed TEXT column is refused (ER_BLOB_KEY_WITHOUT_LENGTH), and syncDeclaredIndexes rethrows, dropping the object's remaining boot steps; nothing declares such an index today, but it blocks the sys_inbox_message (user_id, created_at) half of #35530; traced from code, not measured → p3 as filed · size M (a prefix-length or shadow path for plain indexes, plus the inbox index).

  3. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8

    Picked by card-pick.mjs --order area:data --seat repo:objectstack#8 at 2026-11-28T06:01Z: p3 close-out. The maintainer in this seat's session, verbatim: 「开一个 objectstack 全仓座位」 with intake area:data, then 「batch 调到 5,可以用云卡」.

    Claim: PM loop round 1
    Session: session_017xRBcSAaBEfQpU2yJexSJ8
    Account: sunhaolin
    Branch: claude/issue-35862-mysql-text-index
    Worktree: objectstack-issue-35862
    Domain: domain:server
    Seat: repo:objectstack#8
    File surface: packages/drivers/driver-sql/src/sql-driver-schema-sync.ts (syncDeclaredIndexes), sql-driver-managed-drift.ts / sql-driver-rotation.ts only where the rethrow stops the object's remaining boot steps, co-located tests and a MySQL conformance pin (run by CI's live MySQL lane), one changeset; ⛔ the sys_inbox_message index itself stays out (its card is #35530's other half), no packages/spec/src/** (stop on breach; explain in the report)
    Container & model: M, mode:subagent, model: opus (dispatch-gates --tier: no path-derived mandate; default tier), effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: objectstack — driver-sql syncDeclaredIndexes rethrows ER_BLOB_KEY_WITHOUT_LENGTH for a plain index over a keyed TEXT column, and no caller catches it, so the object's remaining boot steps are skipped every boot | the hash-shadow fallback exists for unique indexes only | MySQL deployments whose object declares a plain index over a keyed text column; none declared today, it blocks #35530's inbox index
    Thread-read: 7042442700
    Premise: read from code by the filer (no MySQL server); the dev measures on CI's live MySQL lane or reports what it could not run.
    Serial constraints cleared: no in-flight claim names these driver-sql files (check-handover.mjs --inflight, seat 3's packages/** claims aside). Textual overlap re-checked with overlap-check.mjs before every push.
    Scope this dispatch: the whole card. Fixes #35862.

  4. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 28, 2026
  5. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8
    os-dev-report

    {
      "issue": 35862,
      "status": "done",
      "branch": "claude/issue-35862-mysql-text-index",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/38225",
      "session": "session_017xRBcSAaBEfQpU2yJexSJ8",
      "premise_still_valid": true,
      "summary": "Landed the card's half (B) only, as `Part of #35862`: in `syncDeclaredIndexes` (packages/drivers/driver-sql/src/sql-driver-schema-sync.ts) a PLAIN index MySQL refuses to key (ER_BLOB_KEY_WITHOUT_LENGTH / ER_TOO_LONG_KEY) is still logged once at error via logDurabilityFailure with the same remedy and still not created or substituted, but the loop now continues instead of throwing, so later indexes and the object's remaining boot steps (old-key retirement, drift reconcile/report, four canonical backfills, MySQL TIMESTAMP/TIME widenings) run. A UNIQUE index the hash-shadow route could not carry still throws (card CONTROL). Premise measured on live MySQL 8.0.46 (installed in the container): with the fix ablated, the inbox-shaped upgrade (TEXT user_id, then maxLength 255 + plain (user_id, created_at) index) rejects initObjects with ER_BLOB_KEY_WITHOUT_LENGTH. Half (A) (converge TEXT to varchar(n), then the inbox index) is a design fork the card leaves open and the dispatch excluded the inbox index; reported in open_questions, no code for it.",
      "tests": "All at head f1c4549df3, local MySQL 8.0.46 (+08:00) + PostgreSQL 16 (Asia/Shanghai), TZ=America/New_York, OS_EXPECT_LIVE_DIALECT_MATRIX=1. (1) vitest run sql-driver-35862 sql-driver-11627-hash-shadow-key sql-driver-keyed-text-mysql: 'Test Files 3 passed (3) / Tests 26 passed (26)'. (2) Ablation via scripts/ablation-replace.mjs, anchor 'if (!unique) {' -> 'if (false) {' (anchor 1->0, blob 3fbbf2dfc9e7->c0aaa9b00fb7), same 3 files: 'Tests 6 failed | 20 passed (26)' (red: both faked refusals, the live MySQL upgrade, the 3 rewritten pins; green: UNIQUE control, PG+SQLite upgrade controls, live hash-shadow control); restored blob == HEAD, git diff HEAD empty. No dist/build in the ablation path: the tests import ../src. (3) Whole package, vitest run --maxWorkers=2 under the lock: 'Test Files 2 failed | 283 passed | 1 skipped (286) / Tests 1 failed | 7052 passed | 12 skipped (7065)'; both failing files environmental: sql-driver-37095-pgvector-extension (local PG has no pgvector; CI uses the pgvector image) and sql-driver-11565-row-byte-budget 'reports InnoDB page-limit refusals' (fails identically with the fix ablated: 'Tests 1 failed | 9 passed (10)'). (4) pnpm --filter @objectstack/driver-sql typecheck: VERDICT command-exit 0 (an earlier run caught TS7006 in the new test, fixed in f1c4549df3). (5) No server: vitest run sql-driver-35862 -> 'Tests 4 passed | 3 skipped (7)'. CI lane for the live pins: 'Temporal Conformance (live PG + MySQL)', step 'Run driver-sql suite against both live servers'; the SQLite layer also runs in Test Core.",
      "gates": "Local subset at f1c4549df3: node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack (5 paths vs merge base 7605e0c9c) derived 69 families; each run with EXIT captured before any pipe; --ran reconciliation with exit codes: '69 derived, 67 run, 2 NOT-MEASURED, 0 UNRUN'. 67 exit 0. NOT MEASURED: pnpm check:dual-build-cjs-loads :: exit 3 and pnpm check:lean-entry-closure :: exit 3, both PREREQUISITE NOT MET (need the whole workspace built; reason: only the driver-sql dependency closure was built here). An earlier pass caught check:facade-delegation-only exit 1 (sql-driver.ts 10077 lines over its 10071 ceiling from a docblock bullet I had added); reverted, now 'sql-driver.ts: 10071 lines, ceiling 10071' exit 0. check-platform-checklist not run: no exported symbol renamed or removed. PR check-runs at f1c4549df3 when read: Governed Surface Queue Guard success; Check Changeset, Check PR Size, Lint (ESLint, CI/release/engine, PM dispatch-gates, docs & code guards, repo & tooling, three scoped lanes), PR-body guards, Type Check (consumer, debt ledger, source, workspace), filter all in_progress; Test Core, Build Core and Temporal Conformance (live PG + MySQL) not yet listed.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "2 relay strokes — POST /repos/objectstack-ai/objectstack/dispatches for pr_create (executed as POST /repos/objectstack-ai/objectstack/pulls + POST /repos/objectstack-ai/objectstack/issues/38225/assignees), and the post-stamped report comment (POST /repos/objectstack-ai/objectstack/issues/35862/comments). git push (probe + 5 pushes) is not a REST write. 0 label writes: no label named by the dispatch, and a changeset exists so no skip-changeset.",
      "open_questions": [
        {
          "question": "Half (A) of #35862: how does a keyed TEXT column already on MySQL reach its declared varchar(n), so the plain (user_id, created_at) inbox index can be built? The card's Expected says 'either schema sync or an os migrate arm', refusing with the rows named when a value is longer than n. The dispatch's two named forms do not fit: the hash shadow is ruled out for non-unique indexes by the existing scope limit in syncDeclaredIndexes (a digest serves no lookup), and the card does not ask for a prefix index.",
          "options": [
            "A1 a drift op (extend the varchar-narrowing family to MySQL TEXT columns, today blocked by isCharacterColumn /char/i) applied by os migrate apply only, category destructive, with a pre-flight that names rows longer than n; boot sync stays additive. Cost: schema-drift.ts + schema-sync apply arm + live MySQL pins, about M; the inbox index then waits for each operator's apply.",
            "A2 schema sync converges at boot (MODIFY to varchar(n) restating NOT NULL/DEFAULT) when no row is longer than n, and refuses with the rows named otherwise. Cost: about M, but it is an exclusive-metadata-lock ALTER at boot, which explainUnkeyableTextColumn today calls 'a deliberate manual floor rather than a boot-time one', so it reverses a recorded disposition.",
            "A3 a plain prefix index (user_id(255), created_at) for non-unique keys only. Cost: S; valid as an access path for a plain index (the keyed-text test file itself says so), but whether ORDER BY created_at is served by it on MySQL is unmeasured, and the card did not choose it."
          ],
          "recommendation": "A1, because it keeps boot DDL additive (the #3728/#2186 contract and the explainUnkeyableTextColumn floor), matches the destructive-op pattern drift already has, and gives the operator the named rows before any data is narrowed; the inbox index card can then ship with an upgrade note pointing at os migrate apply."
        }
      ],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted, not filed — the refusal line from explainUnkeyableTextColumn says 'any uniqueness it declared is currently unenforced' and discusses UNIQUE prefix indexes; on a plain index both are beside the point (shared wording with the UNIQUE path). In the PR's Acceptance notes.",
        "carrier: none · noted, not filed — after the refusal the drift report warns the index is missing and says 'run \"os migrate apply\" to create it'; on MySQL that apply meets the same refusal and reports not-applied (presence check). In the PR's Acceptance notes."
      ],
      "deviations": [
        "File surface: no breach in the landed diff (schema-sync.ts, two existing co-located test files rewritten, one new test file, one changeset). A docblock bullet added to sql-driver.ts was reverted because the facade sits at its line ceiling.",
        "Card scope: PR says 'Part of #35862', not 'Fixes', because half (A) and the inbox index (excluded by the dispatch) remain; the claim line said 'Fixes #35862' for the whole card.",
        "Lock: after ~37 minutes queued behind a dogfood holder, the 3-file ablation run (about 15 s) and one 1-file control re-run (11565 with the fix ablated) ran outside os-verify-lock as a declared narrowing; the full package suite and typecheck ran under the lock.",
        "Did not merge origin/main before opening the PR: 13 incoming commits, one touching driver-sql (a 1-line change in sql-driver-unique-tenancy.test.ts); overlap-check reported a clean merge.",
        "Installed mysql-server-8.0 and postgresql-16 in this container to measure live; both servers stopped before the report."
      ],
      "files_changed": [
        ".changeset/35862-mysql-refused-plain-index-boot-steps.md",
        "packages/drivers/driver-sql/src/sql-driver-schema-sync.ts",
        "packages/drivers/driver-sql/src/sql-driver-35862-refused-plain-index-boot-steps.test.ts",
        "packages/drivers/driver-sql/src/sql-driver-11627-hash-shadow-key.test.ts",
        "packages/drivers/driver-sql/src/sql-driver-keyed-text-mysql.test.ts"
      ],
      "dedupe_words": [
        "ER_BLOB_KEY_WITHOUT_LENGTH plain index",
        "keyed TEXT varchar convergence MySQL",
        "syncDeclaredIndexes rethrow boot steps"
      ]
    }
  6. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#8 · sunhaolin · session_017xRBcSAaBEfQpU2yJexSJ8

    Ruled · 2026-11-28T13:08Z · half (A) of this card: how a keyed TEXT column already stored on MySQL reaches its declared varchar(n). This is the fork reported in os-dev-report 7236521379. It was analysed independently at the fable tier before it was put to the maintainer.

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

Metadata

Metadata

Assignees

Labels

area:datadomain:serverpm:dispatchedpriority:p3

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions