Repository navigation
fix(query): match exact searches without InnoDB phrase positions - #14871
Conversation
InnoDB keeps full-text document IDs in the order transactions assign them, but its phrase search assumes they are also in commit order. When two transactions update indexed rows and the one with the lower document ID commits last, that row stops matching phrase searches until it is rewritten. This is MySQL bug #110448 and reproduces on MySQL 8.4 and MariaDB 10.11 to 11.8. Shared tables put every project's users in one table, so concurrent writes from other projects regularly drop users from exact (quoted) searches. The Users E2E suite hits this in the shared MariaDB lane, where testUpdateUserEmailSearch fails to find a user whose email was just updated. Exact searches now require each indexed word through the full-text index and check the word order with REGEXP against the stored value, so neither depends on the phrase position lists. Terms made only of stopwords or words shorter than the minimum token size keep the phrase form, because InnoDB cannot require words it does not index. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. No issues found — approved ✅. This PR adjusts full-text search query construction in the
Review found no issues meeting the reporting threshold; the two candidates surfaced during scanning were rejected as not defensible. Reviewed commit: 9d861fb |
🟢 Tier S · Ready to mergeExact MySQL and MariaDB searches now use Boolean full-text matching to select indexed terms and a regular expression to verify phrase order, while phrases consisting only of unindexed words retain the previous full-text form. The query tests cover generated SQL and bindings, commit-order regressions, whole-word matching, case behavior, and negated searches on both engines.
📂 Walkthrough · 5
Reviewed |
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…h-out-of-order-commits fix(query): match exact searches without InnoDB phrase positions (cherry picked from commit 6f27981)
What does this PR do?
Exact (quoted) full-text searches on MySQL and MariaDB can miss rows that clearly contain the phrase.
InnoDB records full-text document IDs in the order transactions assign them, but its phrase search assumes those IDs are also in commit order. When two transactions update indexed rows and the one holding the lower document ID commits last, that row stops matching phrase searches until it is written again. Plain word searches still find it. This is MySQL bug #110448. It reproduces on MySQL 8.4 and on MariaDB 10.11, 11.4 and 11.8.
With shared tables, every project's users live in one
_userstable, so writes from other projects regularly interleave with a user update. The shared MariaDB Users E2E lane hits this:UsersCustomServerTest::testUpdateUserEmailSearchsearches"[email protected]"right after the email update and gets no users. The row'ssearchvalue is correct, and a word search finds it, but the phrase search does not.The MySQL builder no longer relies on InnoDB phrase positions for exact searches:
REGEXPchecks that all the words appear in order as whole words, which is the phrase semantics. Matching follows the column collation, so it stays case-insensitive.notSearchnegates the combined expression.Non-exact searches are unchanged.
Test Plan
MariaDBIntegrationTestandMySQLIntegrationTestcases open two connections, update two rows, and commit them in reverse document ID order. Without this change, the exact search returns only the second row on both engines. With it, it returns both. A second case checks that whole words must appear in order, that matching ignores case, and that the negated search returns the complementary rows.MySQLTestcovers the new SQL and bindings, including the stopword-only fallback and the negated form. The query package unit suite passes._APP_DATABASE_SHARED_TABLES=database_db_main,--processes 4 --functional):testUpdateUserEmailSearchfailed in 3 of 15 local runs on the fix(query): tighten function name and cast type parsing in the AST #14866 head, whose search code is the same asmain, and in 0 of 14 runs onmain. The failure only appears when another project's write interleaves with the update. While a failed stack was still up, the row held the rightsearchvalue and a word search found it, but the phrase query found nothing.Related PRs and Issues
Tests / E2E / MariaDB (shared) / Users.Checklist
🤖 Generated with Claude Code