Fix hash index round-trip through st_indexes#4336
Merged
Conversation
When reading indexes back from the st_indexes system table, StIndexAlgorithm::Hash was incorrectly converted to BTreeAlgorithm instead of HashAlgorithm. This caused check_compatible to fail with 'Index algorithm mismatch' on any republish of a module containing hash indexes, since the database schema would report BTree while the module def specified Hash. Introduced in #3976 (Add Hash indices) — the conversion imported HashAlgorithm but used BTreeAlgorithm for the Hash variant.
Contributor
|
The problem only manifests after a restart after publishing a database with a hash index. |
Ensures that IndexAlgorithm -> StIndexAlgorithm -> IndexAlgorithm preserves the algorithm for all variants (BTree, Hash, Direct). Catches the bug where Hash was silently converted to BTree on read-back.
Centril
approved these changes
Feb 18, 2026
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.
Description of Changes
One-line fix in
system_tables.rs: when reading indexes back fromst_index,StIndexAlgorithm::Hashwas incorrectly converted toBTreeAlgorithminstead ofHashAlgorithm.This caused
check_compatibleto fail withIndex algorithm mismatchon any republish of a module containing hash indexes — the database schema would report BTree while the module def specified Hash. Effectively, any database with a hash index was stuck and could not be updated.Root Cause
system_tables.rs:1234in theFrom<StIndexAlgorithm> for IndexAlgorithmimpl:The PR that added hash indices (#3976) imported
HashAlgorithmbut usedBTreeAlgorithmfor the Hash variant conversion.API and ABI breaking changes
None.
Expected complexity level and risk
1 — single word change, restores correct behavior.
Testing
Existing schema tests cover index round-trips. The bug was caught by attempting to republish a module with hash indexes.