influxdata/influxdb · error

should exist

Error message

should exist

What it means

OrderedSet::pop_front (the queue behind the S3-FIFO small/ghost/main queues) checks self.set.is_empty() and then calls set.shift_remove_index(0).expect("should exist"). Because an empty check just passed, index 0 of the IndexSet must exist, so this expect is an internal invariant assertion, not a reaction to caller input. Hitting it means the OrderedSet's internal state is inconsistent (memory corruption or a logic bug in the crate itself).

Source

Thrown at core/object_store_mem_cache/src/cache_system/s3_fifo_cache/ordered_set.rs:86

        assert!(is_new);
    }

    /// Pop entry from the front of the set.
    ///
    /// This may be called on and empty set.
    ///
    /// # Runtime Complexity
    /// This amortizes to `O(1)`.
    ///
    /// If there are only tombstones at the start of the set, this may be in `O(n)` though. The good thing is that the
    /// tombstoes will be gone afterwards, so that will be a one-time clean-up.
    pub(crate) fn pop_front(&mut self) -> Option<T> {
        loop {
            if self.set.is_empty() {
                return None;
            }

            match self.set.shift_remove_index(0).expect("should exist") {
                Entry::Data(o) => {
                    self.memory_size -= o.size();
                    return Some(o);
                }
                Entry::Tombstone(_) => {
                    self.n_tombstones -= 1;
                    // need to continue
                }
            }
        }
    }

    /// Remove element from the middle of the set.
    ///
    /// The relative order of the elements is preserved.
    ///
    /// Returns `true` if the entry was part of the set.
    ///

View on GitHub (pinned to d28e26e048)

Solutions

  1. Treat it as a library bug: capture the panic backtrace (RUST_BACKTRACE=1) and minimize a reproducer against object_store_mem_cache.
  2. If it follows a snapshot restore (new_from_snapshot), inspect/validate the serialized snapshot — corrupted tombstone counters or entry lists can desync bookkeeping.
  3. Audit any local modifications to OrderedSet::remove/insert/retain compaction logic, since those maintain n_tombstones and memory_size invariants.
  4. Report upstream with the reproducer; there is no caller-side input that legitimately triggers this.
Defensive patterns

Strategy: try-catch

Try / catch

// treat invariant panics as data-loss events: contain, report, rebuild
let popped = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| queue.pop_front()));
match popped {
    Ok(v) => v,
    Err(payload) => {
        bug_report(&payload); // open issue w/ backtrace against object_store_mem_cache
        rebuild_state();       // e.g. rehydrate cache from source of truth
        None
    }
}

Prevention

When it happens

Trigger: Calling pop_front on an OrderedSet whose is_empty()/len() bookkeeping disagrees with the underlying IndexSet — only possible via a bug in OrderedSet's insert/remove/compaction paths, a bad snapshot deserialization, or actual memory corruption. No public API input reaches it directly.

Common situations: Effectively unreachable in production; appears when developing/patching this crate (e.g. changing Entry handling or tombstone compaction), after deserializing a hand-crafted/corrupted snapshot, or with a broken custom allocator/Future

Related errors


AI-assisted analysis of influxdata/influxdb@d28e26e048 (2026-08-16). Data as JSON: /api/errors/8e9c44ca76fd59c0. Report an issue: GitHub.