{"record":{"id":"c48eaf9a106d8258","repo":"tikv/tikv","slug":"it-s-a-titan-option","errorCode":null,"errorMessage":"it's a titan option","messagePattern":"it's a titan option","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"components/engine_tirocks/src/db_options.rs","lineNumber":39,"sourceCode":"impl RocksDbOptions {\n    #[inline]\n    pub fn env(&self) -> Option<&Arc<Env>> {\n        match &self.0 {\n            Options::Rocks(opt) => opt.env(),\n            Options::Titan(opt) => opt.env(),\n        }\n    }\n\n    #[inline]\n    pub fn is_titan(&self) -> bool {\n        matches!(self.0, Options::Titan(_))\n    }\n\n    #[inline]\n    pub(crate) fn into_rocks(self) -> DbOptions {\n        match self.0 {\n            Options::Rocks(opt) => opt,\n            _ => panic!(\"it's a titan option\"),\n        }\n    }\n\n    #[inline]\n    pub(crate) fn into_titan(self) -> TitanDbOptions {\n        match self.0 {\n            Options::Titan(opt) => opt,\n            _ => panic!(\"it's not a titan option\"),\n        }\n    }\n}\n\nimpl Default for RocksDbOptions {\n    #[inline]\n    fn default() -> Self {\n        RocksDbOptions(Options::Rocks(Default::default()))\n    }\n}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/tikv/tikv/blob/78aedc1c81ef3f7d8bacc6e9d09f56460f134937/components/engine_tirocks/src/db_options.rs#L21-L57","documentation":"RocksDbOptions::into_rocks (engine_tirocks/src/db_options.rs) panics when the wrapped Options enum holds Titan DB options instead of Rocks DB options. It is called from new_sanitized when sanitizing DB options for a RocksDB engine instance.","triggerScenarios":"Passing Titan-built DbOptions into new_sanitized / any path expecting Rocks DB options — typically when the titan feature is enabled and shared option construction produces the wrong variant.","commonSituations":"Mixing titan and rocks DB-option builders in engine setup; configuration-driven engine selection reusing one options constructor for both backends.","solutions":["Create DbOptions with Options::Rocks (DbOptions::new) for RocksDB engines.","Use into_titan when constructing a Titan engine.","Branch on the Options variant at the construction site (e.g. in new_sanitized callers) before unwrapping."],"exampleFix":"// before\nlet db_opts = RocksDbOptions::new_titan(...).into_rocks(); // panic\n// after\nlet db_opts = RocksDbOptions::new_rocks().into_rocks();","handlingStrategy":"type-guard","validationCode":"fn expects_rocks_db(opts: &RocksDbOptions) -> bool {\n    matches!(opts.as_ref(), Options::Rocks(_))\n}\n// guard before new_sanitized/into_rocks\nif !expects_rocks_db(&db_opts) { /* rebuild as Options::Rocks or use titan engine */ }","typeGuard":"fn as_rocks_db(opts: &RocksDbOptions) -> Option<&rocksdb::DbOptions> {\n    match &opts.0 { Options::Rocks(o) => Some(o), _ => None }\n}","tryCatchPattern":null,"preventionTips":["Construct DB options with the Rocks constructor when the engine is not Titan.","Add a unit test covering new_sanitized for both engine variants.","Keep titan/rocks option selection driven by a single config knob to avoid mixed variants."],"tags":["tirocks","titan","type-mismatch","panic"],"backgroundTag":"engine-options-type-mismatch","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"}