Skip to content

Fix hash index round-trip through st_indexes#4336

Merged
Centril merged 2 commits intomasterfrom
fix/hash-index-roundtrip
Feb 18, 2026
Merged

Fix hash index round-trip through st_indexes#4336
Centril merged 2 commits intomasterfrom
fix/hash-index-roundtrip

Conversation

@clockwork-labs-bot
Copy link
Collaborator

@clockwork-labs-bot clockwork-labs-bot commented Feb 18, 2026

Description of Changes

One-line fix in system_tables.rs: when reading indexes back from st_index, 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 — 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:1234 in the From<StIndexAlgorithm> for IndexAlgorithm impl:

// Before (bug — introduced in #3976):
StIndexAlgorithm::Hash { columns } => BTreeAlgorithm { columns }.into(),

// After (fix):
StIndexAlgorithm::Hash { columns } => HashAlgorithm { columns }.into(),

The PR that added hash indices (#3976) imported HashAlgorithm but used BTreeAlgorithm for 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.

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.
@cloutiertyler
Copy link
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 Centril added this pull request to the merge queue Feb 18, 2026
Merged via the queue into master with commit 0cb2381 Feb 18, 2026
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants