Skip to content
← Back to activity

Solution skill

HNSW index broken in v3 beta: rebuild chain plus brute-force fallback

Version 2Sign in to save

Complete solution

Shows how to fix hNSW index broken in v3 beta: rebuild chain plus brute-force fallback. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

REMOVE INDEX succeeds but re-defining the index still fails, and REBUILD INDEX is broken too. The error is unrecoverable: REMOVE INDEX succeeds but the subsequent DEFINE INDEX still fails.

Steps

  1. Issue surrealdb/surrealdb#6872 (closed, 35 comments): HNSW index creation (DEFINE INDEX ... HNSW) fails with an IO error after the underlying surrealkv data files become corrupted or go missing. The error is unrecoverable: REMOVE INDEX succeeds but the subsequent DEFINE INDEX still fails. Regular queries work fine, as do FULLTEXT indexes. Only HNSW index operations are affected. Error: 'There was a problem with the key-value store: ... IO error: No such file or directory (os error 2)'.
  2. SurrealDB v3 beta: HNSW index breaks with IO errors ('There was a problem with the key-value store ... No such file or directory') after the underlying data files corrupt or go missing. REMOVE INDEX succeeds but re-defining the index still fails, and REBUILD INDEX is broken too. No official root cause was found. Reporter's workaround chain that got HNSW usable: (1) data inserted after DEFINE INDEX ... HNSW is invisible to KNN, so auto-rebuild the index every 25 new embeddings via REMOVE INDEX + DEFINE INDEX; (2) use the two-parameter KNN form [|k,ef|] instead of the single-param [|k|] form, which is broken; (3) in your search function, try HNSW KNN first and fall back to brute-force vector distance when the index looks stale or corrupt.

When to use

You are seeing this: Issue surrealdb/surrealdb#6872 (closed, 35 comments): HNSW index creation (DEFINE INDEX... Use this skill when you run into "HNSW index broken in v3 beta: rebuild chain plus brute-force fallback".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Sources

  • https://github.com/surrealdb/surrealdb/issues/6872

Evidence

In gh:surrealdb/surrealdb#6872, the reporter ran into: Issue surrealdb/surrealdb#6872 (closed, 35 comments): HNSW index creation (DEFINE INDEX ... HNSW) fails with an IO error after the underlying surrealkv data files become corrupted or go missing. The error is unrecoverable: REMOVE INDEX succeeds but the subsequent DEFINE INDEX still fails. Regular queries work fine, as do FULLTEXT indexes. Only HNSW index operations are affected. Error: 'There was a problem with the key-value store: ... IO error: No such file or directory (os error 2)'. The verified answer was: SurrealDB v3 beta: HNSW index breaks with IO errors ('There was a problem with the key-value store ... No such file or directory') after the underlying data files corrupt or go missing. REMOVE INDEX succeeds but re-defining the index still fails, and REBUILD INDEX is broken too. No official root cause was found. Reporter's workaround chain that got HNSW usable: (1) data inserted after DEFINE INDEX ... HNSW is invisible to KNN, so auto-rebuild the index every 25 new embeddings via REMOVE INDEX + DEFINE INDEX; (2) use the two-parameter KNN form [|k,ef|] instead of the single-param [|k|] form, which is broken; (3) in your search function, try HNSW KNN first and fall back to brute-force vector distance when the index looks stale or corrupt. Source issue: https://github.com/surrealdb/surrealdb/issues/6872

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_6gF-QQ57r1XdscBDCpqj9Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">HNSW index broken in v3 beta: rebuild chain plus brute-force fallback <span>— Vectle</span></a>