{"record":{"id":"8e9c44ca76fd59c0","repo":"influxdata/influxdb","slug":"should-exist","errorCode":null,"errorMessage":"should exist","messagePattern":"should exist","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/object_store_mem_cache/src/cache_system/s3_fifo_cache/ordered_set.rs","lineNumber":86,"sourceCode":"        assert!(is_new);\n    }\n\n    /// Pop entry from the front of the set.\n    ///\n    /// This may be called on and empty set.\n    ///\n    /// # Runtime Complexity\n    /// This amortizes to `O(1)`.\n    ///\n    /// If there are only tombstones at the start of the set, this may be in `O(n)` though. The good thing is that the\n    /// tombstoes will be gone afterwards, so that will be a one-time clean-up.\n    pub(crate) fn pop_front(&mut self) -> Option<T> {\n        loop {\n            if self.set.is_empty() {\n                return None;\n            }\n\n            match self.set.shift_remove_index(0).expect(\"should exist\") {\n                Entry::Data(o) => {\n                    self.memory_size -= o.size();\n                    return Some(o);\n                }\n                Entry::Tombstone(_) => {\n                    self.n_tombstones -= 1;\n                    // need to continue\n                }\n            }\n        }\n    }\n\n    /// Remove element from the middle of the set.\n    ///\n    /// The relative order of the elements is preserved.\n    ///\n    /// Returns `true` if the entry was part of the set.\n    ///","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/influxdata/influxdb/blob/d28e26e048401c53cbb98cf2d6ab0cf1e98048ca/core/object_store_mem_cache/src/cache_system/s3_fifo_cache/ordered_set.rs#L68-L104","documentation":"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).","triggerScenarios":"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.","commonSituations":"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","solutions":["Treat it as a library bug: capture the panic backtrace (RUST_BACKTRACE=1) and minimize a reproducer against object_store_mem_cache.","If it follows a snapshot restore (new_from_snapshot), inspect/validate the serialized snapshot — corrupted tombstone counters or entry lists can desync bookkeeping.","Audit any local modifications to OrderedSet::remove/insert/retain compaction logic, since those maintain n_tombstones and memory_size invariants.","Report upstream with the reproducer; there is no caller-side input that legitimately triggers this."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// treat invariant panics as data-loss events: contain, report, rebuild\nlet popped = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| queue.pop_front()));\nmatch popped {\n    Ok(v) => v,\n    Err(payload) => {\n        bug_report(&payload); // open issue w/ backtrace against object_store_mem_cache\n        rebuild_state();       // e.g. rehydrate cache from source of truth\n        None\n    }\n}","preventionTips":["Don't try to 'avoid' this with input checks — it signals an internal bug or corruption.","Keep RUST_BACKTRACE=1 in environments where you'd investigate such panics.","If you consume snapshots (new_from_snapshot), validate/checksum snapshot bytes before restore.","Pin known-good crate versions and add smoke tests over OrderedSet operations when upgrading."],"tags":["rust","internal-invariant","indexset","s3-fifo-cache","unreachable-defensive-panic"],"backgroundTag":"collection-index-invariant","analyzedSha":"d28e26e048401c53cbb98cf2d6ab0cf1e98048ca","analyzedAt":"2026-08-16T19:53:34.623Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}