Declare HNSW index update must run after the node table write (part of #896 fix) - #80
Closed
adsharma wants to merge 1 commit into
Closed
Declare HNSW index update must run after the node table write (part of #896 fix)#80adsharma wants to merge 1 commit into
adsharma wants to merge 1 commit into
Conversation
Index::update implementations either need the OLD value from the node table (FTS re-tokenizes the document being deleted) or the NEW value (HNSW re-scans the updated node's embedding during re-insertion, e.g. in shrinkForNode). Add updateAfterTableWrite() and return true for OnDiskHNSWIndex so NodeTable::update() runs HNSW maintenance after the row is written. Part of the fix for LadybugDB/ladybug#896.
Contributor
Author
|
Closing in favor of a self-contained fix in LadybugDB/ladybug#900: the update ordering is keyed on the serialized index type name in NodeTable::update(), so no Index API change (and no extensions-side change) is needed. The extensions CI builds against ladybug main, which cannot carry the new virtual until #900 lands — making this PR unbuildable in the meantime. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #78 (merged).
Problem
The main-repo fix for LadybugDB/ladybug#896 reorders
NodeTable::update()so indexes are updated around the table write. But the two index kinds have conflicting needs:delete_re-tokenizes the document from the node table, so it needs the old value → must run before the row is written.shrinkForNode()), so it needs the new value → must run after.Running all indexes on one side either crashes HNSW (stale NULL embedding) or corrupts FTS (
FTS index is inconsistent: term ... missing during delete, as caught by CI on LadybugDB/ladybug#900).Change
Add an
Index::updateAfterTableWrite()virtual (defaultfalse, preserving existing behavior for all other index types) and returntrueforOnDiskHNSWIndex.NodeTable::update()(main repo) runs "before" indexes, applies the row write, then runs "after" indexes.Testing
All FTS + vector extension e2e tests pass locally, plus 146 core update/set/index e2e tests.