{"record":{"id":"b43ec23543a8b2f2","repo":"quickwit-oss/tantivy","slug":"failed-to-spawn-meta-file-watcher-thread","errorCode":null,"errorMessage":"Failed to spawn meta file watcher thread","messagePattern":"Failed to spawn meta file watcher thread","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/directory/mmap_directory/file_watcher.rs","lineNumber":65,"sourceCode":"\n                while state.load(Ordering::SeqCst) == 1 {\n                    if let Ok(checksum) = FileWatcher::compute_checksum(&path) {\n                        let metafile_has_changed = current_checksum_opt\n                            .map(|current_checksum| current_checksum != checksum)\n                            .unwrap_or(true);\n                        if metafile_has_changed {\n                            debug!(\"Meta file {path:?} was modified\");\n                            current_checksum_opt = Some(checksum);\n                            // We actually ignore callbacks failing here.\n                            // We just wait for the end of their execution.\n                            let _ = callbacks.broadcast().wait();\n                        }\n                    }\n\n                    thread::sleep(POLLING_INTERVAL);\n                }\n            })\n            .expect(\"Failed to spawn meta file watcher thread\");\n    }\n\n    pub fn watch(&self, callback: WatchCallback) -> WatchHandle {\n        let handle = self.callbacks.subscribe(callback);\n        self.spawn();\n        handle\n    }\n\n    fn compute_checksum(path: &Path) -> Result<u32, io::Error> {\n        let reader = match fs::File::open(path) {\n            Ok(f) => io::BufReader::new(f),\n            Err(e) => {\n                warn!(\"Failed to open meta file {path:?}: {e:?}\");\n                return Err(e);\n            }\n        };\n\n        let mut hasher = Hasher::new();","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/quickwit-oss/tantivy/blob/b5d8deb80c26924e6b007a5b1a7630f35ca64de4/src/directory/mmap_directory/file_watcher.rs#L47-L83","documentation":"Fires in FileWatcher::spawn when thread::Builder::spawn fails to create the background polling thread that watches the meta file (e.g. meta.json) for checksum changes. Typical causes are OS resource exhaustion (thread creation limits, out of memory). Without this thread, watchers registered via watch() would never be notified of meta file changes, so the code treats a failed spawn as fatal instead of silently losing change notifications.","triggerScenarios":"Thrown at src/directory/mmap_directory/file_watcher.rs:65 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check system thread limits (ulimit) and available memory","Reduce the number of concurrently watched directories","Handle the JoinError/IOError from spawn gracefully and fall back to manual polling if a hard failure is undesirable"],"exampleFix":null,"handlingStrategy":"fallback","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"}