{"record":{"id":"6844a5abea22b63f","repo":"tikv/tikv","slug":"panic-6844a5","errorCode":null,"errorMessage":"panic!()","messagePattern":"panic!\\(\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"components/engine_panic/src/misc.rs","lineNumber":13,"sourceCode":"// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.\n\nuse engine_traits::{\n    DeleteStrategy, MiscExt, Range, RangeStats, Result, StatisticsReporter, WriteOptions,\n};\n\nuse crate::engine::PanicEngine;\n\npub struct PanicReporter;\n\nimpl StatisticsReporter<PanicEngine> for PanicReporter {\n    fn new(name: &str) -> Self {\n        panic!()\n    }\n\n    fn collect(&mut self, engine: &PanicEngine) {\n        panic!()\n    }\n\n    fn flush(&mut self) {\n        panic!()\n    }\n}\n\nimpl MiscExt for PanicEngine {\n    type StatisticsReporter = PanicReporter;\n\n    fn flush_cfs(&self, cfs: &[&str], wait: bool) -> Result<()> {\n        panic!()\n    }\n","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/tikv/tikv/blob/78aedc1c81ef3f7d8bacc6e9d09f56460f134937/components/engine_panic/src/misc.rs#L1-L31","documentation":"PanicReporter::new is an intentional `panic!()`: the StatisticsReporter implementation for PanicEngine cannot produce a real reporter because there is no engine statistics to attach to. Constructing it via `StatisticsReporter::new(name)` for a PanicEngine always aborts.","triggerScenarios":"Calling `PanicReporter::new(name)` / `<<PanicEngine as MiscExt>::StatisticsReporter>::new(...)` on the panic engine, e.g. from a statistics-reporting thread or server startup path.","commonSituations":"Starting a TiKV node or a test harness with the panic engine while the statistics reporter is instantiated unconditionally at startup.","solutions":["Start with a real engine (engine_rocks) so the real reporter is constructed","Gate reporter construction on engine type and skip it for PanicEngine","In tests, provide a mock StatisticsReporter instead of relying on PanicEngine's"],"exampleFix":"// before\nlet mut reporter = <PanicEngine as MiscExt>::StatisticsReporter::new(\"tikv\");\n// after\nif engine.is_panic() { return; } // skip stats reporting\nlet mut reporter = <PanicEngine as MiscExt>::StatisticsReporter::new(\"tikv\");","handlingStrategy":"validation","validationCode":"if engine.is_panic() { return; } // do not construct a statistics reporter\nlet reporter = <PanicEngine as MiscExt>::StatisticsReporter::new(\"tikv\");","typeGuard":"fn is_panic_engine(e: &dyn Engine) -> bool { e.as_any().is::<PanicEngine>() }","tryCatchPattern":null,"preventionTips":["Construct the statistics reporter only for real engines","Provide a no-op StatisticsReporter for panic-engine test builds","Add a startup check rejecting panic-engine configs in production"],"tags":["rust","panic","unimplemented","engine-panic","statistics"],"backgroundTag":"unimplemented-stub-panic","analyzedSha":"78aedc1c81ef3f7d8bacc6e9d09f56460f134937","analyzedAt":"2026-09-03T23:31:32.398Z","contentChangedAt":"2026-09-03T23:31:32.398Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}