Skip to content

Conversation

@hubcio
Copy link
Contributor

@hubcio hubcio commented Jan 8, 2026

Server panicked on restart when streams, topics, partitions, or consumer
groups had been deleted, creating gaps in ID sequences.

The issue: slab.insert() auto-assigns sequential IDs (0, 1, 2...),
but after deletions the state file contains non-sequential IDs (e.g.,
{0, 2} after deleting ID 1). On restart, bootstrap called insert()
which returned sequential IDs, causing assertion failures when the
assigned ID didn't match the expected ID from state.

The fix uses Slab::from_iter() via new from_entries() constructors
on Streams, Topics, Partitions, and ConsumerGroups. This correctly
places entities at their original keys regardless of gaps.

@hubcio hubcio changed the title test(server): reproduce slab ID mismatch on restart after deletion fix(server): handle entity ID gaps on bootstrap after deletions Jan 8, 2026
@hubcio hubcio force-pushed the sparse-index branch 2 times, most recently from 9fdc6e9 to 074cd40 Compare January 8, 2026 11:10
Server panicked on restart when streams, topics, partitions, or consumer
groups had been deleted, creating gaps in ID sequences.

The issue: `slab.insert()` auto-assigns sequential IDs (0, 1, 2...),
but after deletions the state file contains non-sequential IDs (e.g.,
{0, 2} after deleting ID 1). On restart, bootstrap called `insert()`
which returned sequential IDs, causing assertion failures when the
assigned ID didn't match the expected ID from state.

The fix uses `Slab::from_iter()` via new `from_entries()` constructors
on Streams, Topics, Partitions, and ConsumerGroups. This correctly
places entities at their original keys regardless of gaps.

Changes:
- Add `from_entries()` to Streams, Topics, Partitions, ConsumerGroups
- Add `set_topics()`, `set_partitions()`, `set_consumer_groups()` setters
- Refactor `load_streams()` to bottom-up construction using `from_entries()`
- Remove ID mismatch assertions (no longer needed)
@hubcio hubcio merged commit e58bee3 into master Jan 8, 2026
55 checks passed
@hubcio hubcio deleted the sparse-index branch January 8, 2026 11:37
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.

3 participants