{"record":{"id":"b50a33f6059a6728","repo":"quickwit-oss/tantivy","slug":"managed-file-lock-poisoned","errorCode":null,"errorMessage":"Managed file lock poisoned","messagePattern":"Managed file lock poisoned","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/directory/managed_directory.rs","lineNumber":221,"sourceCode":"    ///\n    /// This method must be called before the file is\n    /// actually created to ensure that a failure between\n    /// registering the filepath and creating the file\n    /// will not lead to garbage files that will\n    /// never get removed.\n    ///\n    /// File starting by \".\" are reserved to locks.\n    /// They are not managed and cannot be subjected\n    /// to garbage collection.\n    fn register_file_as_managed(&self, filepath: &Path) -> io::Result<()> {\n        // Files starting by \".\" (e.g. lock files) are not managed.\n        if !is_managed(filepath) {\n            return Ok(());\n        }\n        let mut meta_wlock = self\n            .meta_informations\n            .write()\n            .expect(\"Managed file lock poisoned\");\n        let has_changed = meta_wlock.managed_paths.insert(filepath.to_owned());\n        if !has_changed {\n            return Ok(());\n        }\n        save_managed_paths(self.directory.as_ref(), &meta_wlock)?;\n        // This is not the first file we add.\n        // Therefore, we are sure that `.managed.json` has been already\n        // properly created and we do not need to sync its parent directory.\n        //\n        // (It might seem like a nicer solution to create the managed_json on the\n        // creation of the ManagedDirectory instance but it would actually\n        // prevent the use of read-only directories..)\n        let managed_file_definitely_already_exists = meta_wlock.managed_paths.len() > 1;\n        if managed_file_definitely_already_exists {\n            return Ok(());\n        }\n        self.directory.sync_directory()?;\n        Ok(())","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/directory/managed_directory.rs#L203-L239","documentation":"Fires in register_file_as_managed when taking the write lock on meta_informations to record a new managed file before it is created. The RwLock is poisoned — a previous holder panicked — so the managed-path registry cannot be safely updated and registration aborts. This is a poisoned-lock sentinel, not a problem with the file path itself; note that dot-prefixed paths (locks) skip this code entirely. Called from open_write and atomic_write, so the panic aborts writing/registering the file.","triggerScenarios":"Thrown at src/directory/managed_directory.rs:221 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Locate and fix the earlier panic that poisoned the meta_informations lock","Avoid panics while holding the registry lock; return io::Error instead","After recovery, re-open or rewrite the index so the managed file list stays consistent with on-disk files"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b5d8deb80c26924e6b007a5b1a7630f35ca64de4","analyzedAt":"2026-09-05T13:20:51.521Z","contentChangedAt":"2026-09-05T13:20:51.521Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}