spacedriveapp/spacedrive · error
Arena index mismatch: expected {}, got {}
Error message
Arena index mismatch: expected {}, got {} What it means
While deserializing an ephemeral index snapshot, each serialized node is re-inserted into a fresh NodeArena and the returned index is compared against the index the node had when serialized. A mismatch means the arena's allocation order changed between serialize and load: the snapshot is corrupt, was written by a different arena implementation, or the intern/parent layout shifted. The snapshot cannot be trusted for path resolution.
Source
Thrown at core/src/ops/indexing/ephemeral/snapshot.rs:222
for &id in ids {
registry.insert(interned, id);
}
}
// Rebuild arena (convert SerializableFileNode back to FileNode)
let mut arena = super::NodeArena::new()?;
for (expected_idx, serializable_node) in snapshot.arena_entries {
// Intern the name and create NameRef
let interned_name = cache.intern(&serializable_node.name);
let name_ref = super::types::NameRef::new(interned_name, serializable_node.parent);
// Reconstruct FileNode
let mut file_node = super::types::FileNode::new(name_ref, serializable_node.meta);
file_node.children = serializable_node.children;
let actual_idx = arena.insert(file_node)?;
if actual_idx.as_usize() != expected_idx {
anyhow::bail!(
"Arena index mismatch: expected {}, got {}",
expected_idx,
actual_idx.as_usize()
);
}
}
// Reconstruct index using constructor
let index = super::EphemeralIndex::from_snapshot_parts(
arena,
cache,
registry,
snapshot.path_index,
snapshot.entry_uuids,
snapshot.content_kinds,
snapshot.stats,
);
View on GitHub (pinned to 6dfeccf211)
Solutions
- Delete the ephemeral snapshot cache so it is rebuilt from a fresh scan (ephemeral data is rebuildable by design)
- Bump and check a snapshot format version so mismatches are detected explicitly instead of via index comparison
- Write snapshots atomically (temp file + rename) so torn files never appear
Defensive patterns
Strategy: fallback
Validate before calling
// Check the snapshot format version before deserializing
if snapshot.format_version != EXPECTED_SNAPSHOT_VERSION {
// stale/incompatible snapshot: delete and rebuild instead of loading
std::fs::remove_file(&snapshot_path)?;
} Try / catch
match load_snapshot(&path).await {
Ok(index) => index,
Err(e) if e.to_string().contains("Arena index mismatch") => {
// ephemeral data is rebuildable: discard and rescan
let _ = std::fs::remove_file(&path);
rebuild_ephemeral_index_from_scan().await?
}
Err(e) => return Err(e),
} Prevention
- Write snapshots atomically (temp file + rename) to avoid torn files
- Embed and verify a format version and checksum in every snapshot
- Treat ephemeral snapshots as a disposable cache: always be able to rebuild from a scan
When it happens
Trigger: Loading a snapshot written by an older/newer build whose NodeArena insert logic or node ordering differs; truncated or partially-written snapshot file; snapshot written while concurrent inserts mutated the arena.
Common situations: Daemon binary upgraded across a snapshot-format change; crash during snapshot write leaving a torn file; two processes sharing one snapshot path.
Related errors
- Failed to add entry to ephemeral index: {}
- EphemeralEventHandler not connected to FsWatcherService
- Non-local address not supported for indexing yet: {}
- Non-local path not supported yet
- Failed to parse response: {}
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/d2948d94942b8673.
Report an issue: GitHub.