Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
- Incident:
32f54981401fd3888702f2dab8702d2e62c6997a. - Revalidated on current main:
b75086c6fab613b147bff4e474dddac7e237c637. - Also reproduced the distributed-path defect on the older
52eecb55bee9b55e776d09c64dfbaa55d5db8f1f.
Other Environment Information
- Incident: Run 36881937434 / MOTR Job 110585528706,
weekly-shadow-1x2, 1 TP CN + 2 AP CNs, 55 GiB per CN, 16 GiB FileService memory cache. - The MOTR connection was directly to the TP CN, not through the proxy. The affected case was
issue_29079_29276_fulltext_query_contracts. - Previous run: 36734661643, MO
c2abd6a54b7cd3e13c1b1494388cd7a81b8369d4. Both runs used MOTR957dd0cand the same test SQL/golden. - Controlled validation: isolated local macOS embedded cluster, 3 CNs, real MySQL frontend, real source-table persistence, real remote pipelines and internal index INSERTs. No production cluster was modified.
Actual Behavior
There is a placement-dependent correctness defect in the distributed synchronous index rebuild path. A remote fulltext2_create / hnsw_create operator can execute its index-table INSERTs successfully against a remote transaction workspace, but those writes do not become part of the coordinator's committed rebuild. ALTER ... FORCE_SYNC returns success while indexed queries silently miss rows.
Confirmed in controlled execution:
- A local FULLTEXT2 build over three committed source rows returns the expected matches. The metadata and chunk tables each contain one row.
- Route only the subsequent synchronous rebuild through the normal remote-pipeline machinery.
- The remote FULLTEXT2 builder receives all three non-null source rows, tokenizes them, finishes a three-document segment, and emits the metadata/chunk INSERTs. Both INSERTs report
AffectedRows=1, no error. - After the successful ALTER commits, both hidden tables contain zero rows and all six tested MATCH variants return empty results. The source rows remain intact.
- An ordinary HNSW control using
[1,0],[2,0],[3,0]likewise changes from correct Top-K results and nonempty hidden tables to empty indexed results and zero hidden-table rows after a remote rebuild. This does not depend on extreme numeric values.
This is different from temporarily serving an old cached generation: the controlled failure has no committed replacement metadata/chunks, including on the initiating connection.
Observed in the incident, but not yet completely attributed to that mechanism:
| Query group | Expected | Incident result |
|---|---|---|
| FULLTEXT2 26-byte token: NL, BM25, quoted boolean, mandatory boolean | IDs 1,3 | Empty |
FULLTEXT2 hello + 26-byte token |
ID 3 | Empty |
| FULLTEXT2 23-byte control token | ID 2 | Empty |
| FULLTEXT2 scalar / anti / correlated subquery forms, five queries | Matching source rows | Empty |
| Equivalent classic FULLTEXT controls | Matching source rows | Correct |
All 34 SQL statements in the fulltext contract case executed; the case failed on 11 result mismatches, not on SQL errors. The six long-token queries passed in the previous run, while the five FULLTEXT2 subquery forms were already failing there.
The HNSW extreme-score case also unexpectedly succeeded. Importantly, its server log at 2026-10-01 21:59:50.258962 UTC / 2026-10-02 05:59:50.258962 CST reported:
hnsw/search.go:439
loaded 0 generation(s), rows=0, build_ts=unknown
Its source table had three rows. Consequently, this observation alone is not evidence that the numeric overflow guard stopped working: an empty model can make the query succeed without reaching score validation.
Expected Behavior
- A successful synchronous rebuild must persist all index writes in the rebuilding transaction, regardless of the selected scan worker.
- A nonempty source must not become a queryable empty index because the builder ran remotely.
- If a side-effecting build TVF cannot safely execute in a remote mirror transaction, the compiler must not schedule it there, or must fail explicitly before replacing the existing generation.
- This contract concerns the committed index state; it does not require an immediate cluster-wide cache invalidation barrier.
Steps to Reproduce
The three-row SQL below requires a controlled remote-placement harness to reproduce. Ordinary default scheduling is a passing control, not a standalone deterministic reproducer.
CREATE DATABASE ft_remote_rebuild;
USE ft_remote_rebuild;
SET experimental_fulltext2_index=1;
CREATE TABLE docs(id INT PRIMARY KEY, body VARCHAR(200));
INSERT INTO docs VALUES
(1,'bbbbbbbbbbbbbbbbbbbbbbbbbb'),
(2,'aaaaaaaaaaaaaaaaaaaaaaa'),
(3,'hello bbbbbbbbbbbbbbbbbbbbbbbbbb');
CREATE FULLTEXT2 INDEX ft ON docs(body) WITH PARSER ngram;
-- Before the rebuild: 1,3.
SELECT id FROM docs
WHERE MATCH(body) AGAINST('bbbbbbbbbbbbbbbbbbbbbbbbbb') ORDER BY id;
-- Enable the remote-placement probe only around this statement.
ALTER TABLE docs ALTER REINDEX ft FULLTEXT2 FORCE_SYNC;
-- In a failing remote placement: empty, although the source still has 3 rows.
SELECT id FROM docs
WHERE MATCH(body) AGAINST('bbbbbbbbbbbbbbbbbbbbbbbbbb') ORDER BY id;
SELECT id FROM docs
WHERE MATCH(body) AGAINST('aaaaaaaaaaaaaaaaaaaaaaa') ORDER BY id;
SELECT id,body FROM docs ORDER BY id;Harness details, so the test's limits are explicit:
- Use
embed.StartTestCluster(embed.WithCNCount(3))and connect through CN0's public MySQL frontend. - Persist the tiny source before rebuilding. The existing test fault
objectio.FJ_CNWorkspaceForceFlushwas used to make source object placement available without loading millions of rows. - Save
plan.GetForceScanOnMultiCN(), setplan.SetForceScanOnMultiCN(true)only forALTER ... FORCE_SYNC, and restore it immediately afterward. This bypasses the tiny query's execution-classification threshold; it does not replace the builder, SQL executor, transaction implementation, or remote transport with mocks. - Verify from the builder trace that the source-bearing worker differs from the coordinator and uses
Txn.Mirror=true. Object placement can leave a particular table's source on the coordinator; such a placement passes and must not be mislabeled as a failed reproduction. - Query
mo_catalog.mo_indexesfor the hidden metadata/storage names, and count their rows before/after ALTER. Record actual query rows, not just the Go test exit code. - Add the ordinary HNSW three-vector control above; compare indexed Top-K before/after its
FORCE_SYNCand confirm the base table still contains three rows.
The same side-effecting APPLY can attach to distributed scan scopes under normal scheduling; IsSingle only constrains each scope's parallelism. The small-row harness forces placement to expose that path cheaply. We have not yet reproduced the incident's exact natural placement selection without the probe.
Additional information
Code facts and failure chain
All links below are pinned to the incident commit.
Compile.compileApplyattaches CROSS APPLY to each input scope. For these build TVFs,IsSinglesetsMcpu=1; it does not gather inputs onto the transaction-owning coordinator. Themo_view_columnsorigin-session exception does not cover them.generateProcessHelperrestores a transaction from its snapshot.newTxnOperatorWithSnapshotmarks it as a mirror. The remote server binds a separate localdisttae.Transactionworkspace.sqlexec.RunSqlborrows that process transaction viaWithTxn(...).txnExecutor.commitdoes not commit executor-borrowed transactions. The remote builder's ordinary workspace writes are not returned as coordinator workspace entries by the SELECT pipeline result path.FULLTEXT2 buildAndRegisterCDCclears the old base/tail in the coordinator rebuild transaction;fulltext2CreateState.sealSegmentwrites replacement metadata/chunks through the borrowed process transaction. A remote replacement is therefore missing from the committed state.hnswCreateState.endalso performs clear/rebuild SQL through its process transaction. A zero-input local scope can clear while the source-bearing remote scope writes an uncommitted replacement.
Counterfactual and negative controls
A temporary diagnostic change gathered inputs onto c.newMergeScope(rs) only for fulltext2_create / hnsw_create, leaving the forced distributed source scan unchanged. On the incident code this restored:
- all six long-token query results;
- direct/scalar/correlated short-word matches;
- nonempty metadata/chunk tables;
- normal HNSW Top-K;
- the extreme HNSW query's expected 20101 overflow error.
This is a causal diagnostic, not a published or fully reviewed production fix. The temporary change was removed.
The default three-row SQL also passes without forced placement, including a local 1 TP + 2 AP role configuration. Merely having multiple CNs is not sufficient to reproduce.
Regression status and remaining uncertainty
- The distributed-path defect was reproduced on older
52eecb55..., incident32f54981..., and latest checked mainb75086c6...; it is not fixed in latest main. - No introducing commit is established. The previous-night pass does not prove the latest 15 commits introduced this defect. Different physical object/worker placements produce different outcomes even on the same code.
- The incident logs show empty HNSW model state and successful synchronous rebuild statements, but do not retain the decisive per-builder CN/mirror/workspace trace. Therefore the local defect is confirmed, while attributing every incident mismatch to it remains a leading explanation, not a completed production RCA.
- Internal index SQL disables normal executor SQL logging. Absence of INSERT lines in the incident log is not evidence that INSERTs did not execute. Similarly, a build SELECT's zero result batch size does not prove that its source scan was empty.
- No base-table data loss, OOM, or restart is demonstrated by this finding. The demonstrated impact is silent incorrect indexed query results and loss of the replacement index state.
Existing issue comparison
- [Bug]: scalar, anti, and correlated subqueries prevent FULLTEXT MATCH index rewrite #29079: rejected MATCH rewrite with scalar/anti/correlated subqueries. Here the SQL executes and the index can be empty even for a direct MATCH.
- [Bug]: fulltext2 NL, quoted boolean, and BM25 search of a word longer than 23 bytes looks up the raw string and misses the truncated index token #29276: query/index long-token normalization mismatch. Here the 23-byte control and short-word queries also fail when the physical index is empty; valid local generations pass long-token controls.
- [Bug]: FULLTEXT2 FORCE_SYNC rebuild leaves warm remote CN on the old generation #29080 / [Bug]: multi-CN HNSW query CN serves stale model after async generation update #27632: remote caches serve an old generation. Here the controlled hidden tables themselves become empty, so eventual cache consistency is not an explanation.
- [Bug]: COPY ALTER leaves an unaffected FULLTEXT2 index empty #28837 / open [Bug] CI BVT fulltext2_copy_alter misses expected rows #28985: COPY ALTER lifecycle / post-copy missing rows. This reproduction uses an ordinary table and explicit synchronous reindex, with no COPY ALTER.
- [Bug]: DATA BRANCH leaves FULLTEXT2 and HNSW indexes uninitialized but queryable #27950: inherited branch indexes are not initialized asynchronously. This reproduction uses no branch, and explicit
FORCE_SYNCcan itself produce the bad committed state. - [Bug]: HNSW rewrite returns inconsistent or non-finite distance expression values #29050: extreme numeric score validation. A valid local generation still rejects the invalid score; empty-model execution must be separated from that contract.
Duplicate searches covered FULLTEXT2/HNSW + remote, empty, rebuild, FORCE_SYNC, mirror transaction, and workspace across recent open/closed issues, followed by reading the plausible matches above. No issue accurately tracking this remote builder write/commit ownership defect was found.
Activity
LeftHandCold commentedon Oct 2, 2026
Confirmed defect and main fix
Submitted PR #29568,
targeting main, head
41238efc092c1f013a61d047a119982b242ccae8, based ond50a2d475a406829f67127fef7b2ad4abc1c1d3d.The controlled root cause is a transaction-workspace ownership defect,
not long-token normalization or ordinary cache freshness:
IsSingleestablishes one worker per scope, not one transaction-owningcoordinator for the statement. Executor-borrowed transactions are not
independently committed. For HNSW, a local zero-input builder can additionally
clear the old generation while the source-bearing remote builder's
replacement is lost. The base-table rows remain intact in this reproduction.
Fix boundary
The patch opts only
fulltext2_createandhnsw_createinto coordinatorplacement through the existing plugin registry. The compiler gathers their
inputs through its existing merge scope before invoking the writer, for both
APPLY and child-bearing table-function execution. Standalone TVFs already run
locally. This makes the original transaction own clear and replacement writes
together, without adding a remote-write protocol or changing commit behavior.
Source scans remain distributed and retain their parallelism. Searches and
ordinary TVFs retain their placement. No tokenizer/search algorithm, on-disk
format, WAL/Raft, retry, background worker, or generation-cache changes.
Pre-fix / post-fix evidence
The retained regression uses a real public MySQL frontend, two CNs, three
rows per algorithm, and public DN flush to persist the source. It uses the
existing scoped multi-CN classification hook only for the scan probe and
rebuild, and rebuilds from both coordinators. This does not mock the
builder, executor, transaction, storage, or remote transport. Default tiny
query scheduling remains a passing control rather than a standalone trigger.
52eecb55: empty instead of IDs 1,352eecb55: empty instead of IDs 1,2,3b75086c6: all four CROSS/OUTER builder cases fail; view/search controls passFinal local validation completed with exit 0:
-vet=all, and full-racetests.pkg/tests/sqlintegration/multicn: all three tests executed andpassed, 61.806s, including existing join/view placement controls.
-race: 20.48s, both algorithms androllback/empty-input checks passed.
source evidence reused across the final rebase.
invalid-input and empty/end controls.
These tests ran locally on macOS, not server 50 or the original TKE
environment. The new public regression costs about 19 seconds in normal mode.
The seven-file patch has approximately 40 added production lines; the rest
is focused test coverage. Final self-review found no unresolved blockers.
Remaining boundaries
the decisive builder-CN/mirror trace, so every historical mismatch is not
independently attributed by this fix.
introduced by the incident day's commits.
Full-scale build throughput/memory was not benchmarked. Ordinary search
runtime is unchanged; this is not a claim of zero risk for all workloads.
LeftHandCold commentedon Oct 4, 2026
Verified the fix against the latest completed scheduled Main nightly and the mechanism-specific regression. Closing the confirmed remote-builder transaction/workspace ownership defect as fixed by #29568.
d59cc02ef6ca68f340c9570e56f7eb71d90e42e7. Run 37135891536 deployed MOc1c8ea97477dd12a79cb1991d283905ca9ebf3a5; the fix is its ancestor, verified by commit comparison.issue_29079_29276_fulltext_query_contracts34/34 andissue_29050_hnsw_score_consistency17/17 passing. Both SQL and expected-result files are byte-identical to incident MOTR957dd0c; current MOTR is569655bad03d26de8022ee8944912c3c1da877d1. The HNSW overflow assertion is still enforced.TestIssue29566IndexRebuildCoordinatoruses a real two-CN cluster, forced distributed source scans with peer-plan verification, and rebuilds through both coordinators. It checks FULLTEXT2/HNSW indexed results, replacement metadata generation, intact source rows, empty-input handling and rollback. The PR Ubuntu UT job explicitly shows this test running and the UT stage succeeding. Its source is unchanged in the nightly-tested MO. This supplements the existing controlled before/after validation; ordinary nightly placement alone would not establish the remote-path fix.Scope: Main's confirmed synchronous rebuild ownership defect. The overall nightly/MOTR job still has unrelated failures. This does not certify a 4.2 backport, all cache-invalidation behavior, or prove every historical mismatch had the same cause.
test: extend multi-CN irregular index rebuild DML coverage (#29688)