quickwit-oss/quickwit · error
The right iterator should not be empty.
Error message
The right iterator should not be empty.
What it means
When both iterators peek Some and left key > right key, right.next() must return the peeked element. The expect asserts the right iterator is not empty; failure means the right iterator breaks the Iterator contract or was mutated concurrently.
Solutions
- Make the right iterator consistent between peek and next
- Snapshot the underlying collection before diffing instead of iterating live data
- Do not share the iterator across threads without synchronization
- Fix any local modifications to quickwit-common::sorted_iter
Example fix
// before
let right = self.right.next().expect("The right iterator should not be empty.");
// after
let right = match self.right.next() { Some(r) => r, None => return None }; Defensive patterns
Strategy: type-guard
Validate before calling
// Materialize the right sequence before diffing let right: Vec<_> = right_iter.collect();
Type guard
fn right_stable<I: Iterator + Clone>(it: &I) -> bool { let mut p = it.clone().peekable(); p.peek().is_some() == p.next().is_some() } Try / catch
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| diff_loop())).unwrap_or_else(|_| eprintln!("diff panicked on right iterator")); Prevention
- Never advance the right iterator from another thread while diffing
- Use owned, static data for the right side of comparisons
- Fix custom iterators that return None right after a Some peek
- Keep sorted_iter.rs unmodified upstream
When it happens
Trigger: SortedIterator diff where the right iterator's next() returns None right after peek() returned Some — caused by a misimplemented iterator or concurrent advancement of the right source.
Common situations: Custom iterators over live data (e.g. shard lists refreshed mid-iteration); shared iterators advanced from multiple threads; local patches to sorted_iter.rs.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- The left iterator should not be empty.
- More memory released than allocated, should never happen.
- storage factory and config backends should match
- subscription map should exist
- 1 is always non-zero.
AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08).
Data as JSON: /api/errors/5dd4ce598bed35bf.
Report an issue: GitHub.
Appendix: source
Thrown at quickwit/quickwit-common/src/sorted_iter.rs:77
let left = self
.left
.next()
.expect("The left iterator should not be empty.");
Some(Diff::Removed(left))
}
Ordering::Equal => {
let left = self
.left
.next()
.expect("The left iterator should not be empty.");
self.right.next();
Some(Diff::Unchanged(left))
}
Ordering::Greater => {
let right = self
.right
.next()
.expect("The right iterator should not be empty.");
Some(Diff::Added(right))
}
},
(Some(_), None) => {
let left = self
.left
.next()
.expect("The left iterator should not be empty.");
Some(Diff::Removed(left))
}
(None, Some(_)) => {
let right = self
.right
.next()
.expect("The right iterator should not be empty.");
Some(Diff::Added(right))
}
(None, None) => None,View on GitHub (pinned to a39730c5cd)