Skip to content

fix(storage): degrade topic purge to LIKE when the FULLTEXT index is unusable - #506

Merged
loveRhythm1990 merged 2 commits into
matrixorigin:mainfrom
loveRhythm1990:fix/purge-topic-fulltext-degrade
Nov 18, 2026
Merged

loveRhythm1990 merged 2 commits into
matrixorigin:mainfrom
loveRhythm1990:fix/purge-topic-fulltext-degrade

Conversation

@loveRhythm1990

@loveRhythm1990 loveRhythm1990 commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #247

Where #247 stands on main

Most of the issue is already fixed. fulltext_rows_or_degraded classifies the unusable-index error (20301 column word does not exist), and the memory search paths and the graph node search degrade to a scoped LIKE scan. One FULLTEXT query still failed the whole request:

find_ids_by_topic, the lookup behind purge(topic=...). Its fast path ended in .map_err(db_err)?, so the LIKE scan directly below it was only reachable when the query succeeded with zero rows. With a broken index, purge by topic returned a database error.

Change

memoria-storage/src/store.rs: run the fast path through fulltext_rows_or_degraded. An unusable index falls through to the existing LIKE scan, and so does an empty pattern. Other database errors still propagate.

Tests

broken_fulltext_index_degrades_topic_lookup_and_other_errors_surface breaks the index for real instead of simulating it. In an isolated database it replaces the hidden FULLTEXT index table with one that has no word column, which makes MatrixOne answer 20301 column word does not exist. It then checks:

  • the injected failure really classifies as the recognized unusable-index error,
  • the topic lookup still returns the owner's active matches through LIKE, and not other owners' rows or inactive rows,
  • with the index table missing entirely (an unrelated error) the lookup still returns a database error.

On the old code this test fails with Database("... 20301 ... column word does not exist"). With the change it passes. Skipped without DATABASE_URL, like the other database tests.

What changed since the first push

The first version also touched the branch pick candidate search in git_tools.rs. I reverted that part:

  • The pick query joins the target table and filters with OR. In a MatrixOne v4.2.8 container that shape answers 20105 not supported: MATCH() AGAINST() function cannot be replaced by FULLTEXT INDEX... whether the index is healthy or broken. The existing code already degrades 20105, so a 20301 branch there is unreachable.
  • A pick test on a really broken index passed on the old code as well, which confirmed it. The change had no effect, so it is dropped along with the helper it needed.
  • Consequence: the pick-by-retrieval full-text score looks like it is never applied on that MatrixOne version, because the query always degrades. That is existing behavior and out of scope here. I only checked v4.2.8, not other versions.

Verification

  • cargo test -p memoria-storage --lib with a MatrixOne container: 69 passed, 1 ignored.
  • cargo test -p memoria-storage --test store_crud -- topic: passes.
  • cargo check -p memoria-mcp builds. cargo fmt --check reports nothing in the changed ranges. Existing findings elsewhere are untouched.

…T is unusable (matrixorigin#247)

Two FULLTEXT queries still failed the whole request on the recognized
unusable-index error (20301 column word does not exist):

- find_ids_by_topic, the lookup behind purge(topic): its fast path used
  map_err(db_err)? so the LIKE scan right below it was unreachable on error.
- the branch pick candidate search in git_tools, which matched error text by
  hand and only knew the empty-pattern case.

Route the first through fulltext_rows_or_degraded and export
is_degradable_fulltext_error for the second, so both use the single
classification in store.rs. Other database errors still propagate.
@mergify

mergify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

…test; drop the pick change

Review feedback: the topic lookup test used a simulation hook that the old code
never reached, so it passed on the old code too.

Replace it with a test that swaps the hidden FULLTEXT index table for one
without a word column in an isolated database. MatrixOne then answers 20301
column word does not exist, the unusable state from matrixorigin#247. The old lookup fails
this test with that error. The test also checks that an unrelated error (the
index table missing entirely) still propagates.

Revert the git_tools pick change and its helper. The pick candidate query joins
the target table and filters with OR, a shape for which MatrixOne answers 20105
not supported whether the index is healthy or broken. That case was already
degraded, so the 20301 branch there is unreachable and had no effect.
@loveRhythm1990 loveRhythm1990 changed the title fix(storage): degrade topic purge and branch pick search when FULLTEXT is unusable fix(storage): degrade topic purge to LIKE when the FULLTEXT index is unusable Nov 18, 2026
@loveRhythm1990
loveRhythm1990 merged commit ed4cadd into matrixorigin:main Nov 18, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Full-text search failures fail retrieval hard instead of degrading to LIKE

2 participants