clockworklabs/SpacetimeDB · error · io::Error
[ ]
Error message
{} [{}]: {} What it means
This is not a standalone failure but the context wrapper with_segment_context: it re-wraps any underlying io::Error raised during a segment operation as '<segment-path-or-offset> [<operation>]: <source>', preserving the original ErrorKind. The text after the colon is the real cause; the prefix tells you which segment file and which operation (e.g. 'determining segment file size for resume') failed.
Solutions
- Read the trailing source text and match on the preserved ErrorKind to dispatch handling
- Use the segment path in the prefix to inspect that exact file (existence, permissions, size)
- Fix the underlying condition (restore the file, repair permissions, free space) rather than reacting to the wrapper text
Defensive patterns
Strategy: try-catch
Type guard
fn segment_context_of(err: &io::Error) -> Option<(&str, &str)> {
// shape: '<label> [<context>]: <source>'
let msg = err.to_string();
let (head, source) = msg.split_once(": ")?;
let context = head.rsplit_once(" [")?.1.strip_suffix(']')?;
Some((context, source))
} Try / catch
match repo.open_segment_reader(offset) {
Ok(r) => Ok(r),
Err(e) => {
if let Some((context, source)) = segment_context_of(&e) {
tracing::error!(segment = offset, context, source, kind = ?e.kind(), "segment io failed");
}
// dispatch on the preserved kind, not the wrapper text
match e.kind() {
io::ErrorKind::NotFound => /* file gone: restore or skip */,
_ => return Err(e),
}
}
} Prevention
- Always dispatch on e.kind(); the wrapper preserves it
- Log the full message: the prefix names the segment file, the suffix names the root cause
- Monitor the repo directory for external deletion/permission changes
When it happens
Trigger: Any underlying OS/IO failure inside segment handling: the segment file was deleted or moved (NotFound), permissions changed (PermissionDenied), disk full (StorageFull), or a read hit EOF (UnexpectedEof) while a context-wrapped operation runs.
Common situations: Another process or operator removing/renaming segment files under a running node; read-only mounts; quota exhaustion; copying a repo directory while it is being read.
Related errors
- all-zeroes commit header
- allocation size overflow
- Delete for non-existent row when replaying transaction
- Error looking up name for truncated table
- error reading commit header
AI-assisted analysis of clockworklabs/SpacetimeDB@3653d2ed49 (2026-08-20).
Data as JSON: /api/errors/468b88b0b3e75ae9.
Report an issue: GitHub.
Appendix: source
Thrown at crates/commitlog/src/repo/mod.rs:473
/// Obtain the canonical [CompressOnce] compressor for segments.
///
/// The compressor will create seekable [Zstd] archives with a max frame size
/// of 4KiB. That is, seeking to an arbitrary byte offset (of the uncompressed
/// segment) within the archive will decompress 4KiB of data on average.
pub fn segment_compressor() -> Zstd {
Zstd {
max_frame_size: Some(0x1000),
}
}
fn segment_label<R: Repo>(repo: &R, offset: u64) -> String {
repo.segment_file_path(offset)
.unwrap_or_else(|| format!("offset {offset}"))
}
fn with_segment_context<R: Repo>(context: &'static str, repo: &R, offset: u64, source: io::Error) -> io::Error {
io::Error::new(
source.kind(),
format!("{} [{}]: {}", segment_label(repo, offset), context, source),
)
}
/// Allocate [Options::max_segment_size] of space for [FileLike]
/// if the `fallocate` feature is enabled,
/// and [Options::preallocate_segments] is `true`.
///
/// No-op otherwise.
#[inline]
pub(crate) fn fallocate(_f: &mut impl FileLike, _opts: &Options) -> io::Result<()> {
#[cfg(feature = "fallocate")]
if _opts.preallocate_segments {
_f.fallocate(_opts.max_segment_size)?;
}
Ok(())View on GitHub (pinned to 3653d2ed49)