{"record":{"id":"4ce7be3c382690f6","repo":"nautechsystems/nautilus_trader","slug":"intervals-are-not-disjoint-after-resetting-file-na","errorCode":null,"errorMessage":"Intervals are not disjoint after resetting file names","messagePattern":"Intervals are not disjoint after resetting file names","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/persistence/src/backend/catalog_operations.rs","lineNumber":1657,"sourceCode":"                    self.object_store.clone(),\n                    &object_path,\n                    \"ts_init\",\n                )\n                .await\n            })?;\n\n            let new_filename =\n                timestamps_to_filename(UnixNanos::from(first_ts), UnixNanos::from(last_ts));\n            let new_file_path = make_object_store_path(directory, &[&new_filename]);\n            let new_object_path = ObjectPath::from(new_file_path);\n\n            self.move_file(&object_path, &new_object_path)?;\n        }\n\n        let intervals = self.get_directory_intervals(directory)?;\n\n        if !are_intervals_disjoint(&intervals) {\n            anyhow::bail!(\"Intervals are not disjoint after resetting file names\");\n        }\n\n        Ok(())\n    }\n\n    /// Finds all leaf data directories in the catalog.\n    ///\n    /// A leaf directory is one that contains data files but no subdirectories.\n    /// This method is used to identify directories that can be processed for\n    /// consolidation or other operations.\n    ///\n    /// # Returns\n    ///\n    /// Returns a vector of directory path strings representing leaf directories,\n    /// or an error if directory traversal fails.\n    ///\n    /// # Errors\n    ///","sourceCodeStart":1639,"sourceCodeEnd":1675,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/persistence/src/backend/catalog_operations.rs#L1639-L1675","documentation":"Raised by reset_file_names after it renames all files in a directory based on their intervals. After renaming, it re-reads the directory intervals and verifies they are disjoint (no overlapping timestamp ranges). If files overlap, the rename operation would produce an inconsistent catalog, so it fails with this invariant violation.","triggerScenarios":"Calling reset_all_file_names or reset_data_file_names on a catalog directory whose files contain overlapping timestamp ranges (e.g. duplicate/overlapping writes, files appended outside normal write paths, or a corrupted catalog).","commonSituations":"Catalogs assembled from multiple ingestion runs that wrote overlapping windows, concurrent writers without proper session isolation, or manually restored/merged backup files.","solutions":["Inspect the directory intervals and remove or re-ingest the overlapping files before resetting names.","Run consolidation (consolidate_data_by_period_generic) to merge overlapping files into coherent intervals.","Restore the catalog from a known-good backup if the overlap is due to corruption.","Identify the writer that produced overlapping files and fix session/time-window bookkeeping before re-running reset."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let intervals = catalog.get_directory_intervals(&directory)?;\nif !are_intervals_disjoint(&intervals) {\n    // consolidate or de-duplicate before resetting names\n    eprintln!(\"directory has overlapping intervals; consolidate first\");\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = catalog.reset_all_file_names() {\n    if e.to_string().contains(\"Intervals are not disjoint\") {\n        // inspect overlapping files and consolidate/remove them, then retry\n    }\n}","preventionTips":["Avoid running multiple writers against the same catalog directory concurrently.","Run consolidation after merging catalogs or restoring partial backups.","Audit interval overlap periodically on catalogs assembled from multiple sources."],"tags":["rust","persistence","data-integrity","invariant-violation"],"backgroundTag":"internal-invariant-violation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}