nautechsystems/nautilus_trader · error · anyhow::Error

Intervals are not disjoint after resetting file names

Error message

Intervals are not disjoint after resetting file names

What it means

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.

Source

Thrown at crates/persistence/src/backend/catalog_operations.rs:1657

                    self.object_store.clone(),
                    &object_path,
                    "ts_init",
                )
                .await
            })?;

            let new_filename =
                timestamps_to_filename(UnixNanos::from(first_ts), UnixNanos::from(last_ts));
            let new_file_path = make_object_store_path(directory, &[&new_filename]);
            let new_object_path = ObjectPath::from(new_file_path);

            self.move_file(&object_path, &new_object_path)?;
        }

        let intervals = self.get_directory_intervals(directory)?;

        if !are_intervals_disjoint(&intervals) {
            anyhow::bail!("Intervals are not disjoint after resetting file names");
        }

        Ok(())
    }

    /// Finds all leaf data directories in the catalog.
    ///
    /// A leaf directory is one that contains data files but no subdirectories.
    /// This method is used to identify directories that can be processed for
    /// consolidation or other operations.
    ///
    /// # Returns
    ///
    /// Returns a vector of directory path strings representing leaf directories,
    /// or an error if directory traversal fails.
    ///
    /// # Errors
    ///

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Inspect the directory intervals and remove or re-ingest the overlapping files before resetting names.
  2. Run consolidation (consolidate_data_by_period_generic) to merge overlapping files into coherent intervals.
  3. Restore the catalog from a known-good backup if the overlap is due to corruption.
  4. Identify the writer that produced overlapping files and fix session/time-window bookkeeping before re-running reset.
Defensive patterns

Strategy: validation

Validate before calling

let intervals = catalog.get_directory_intervals(&directory)?;
if !are_intervals_disjoint(&intervals) {
    // consolidate or de-duplicate before resetting names
    eprintln!("directory has overlapping intervals; consolidate first");
}

Try / catch

if let Err(e) = catalog.reset_all_file_names() {
    if e.to_string().contains("Intervals are not disjoint") {
        // inspect overlapping files and consolidate/remove them, then retry
    }
}

Prevention

When it happens

Trigger: 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).

Common situations: Catalogs assembled from multiple ingestion runs that wrote overlapping windows, concurrent writers without proper session isolation, or manually restored/merged backup files.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/4ce7be3c382690f6. Report an issue: GitHub.