{"record":{"id":"468b88b0b3e75ae9","repo":"clockworklabs/SpacetimeDB","slug":"error-468b88","errorCode":null,"errorMessage":"{} [{}]: {}","messagePattern":"\\{\\} \\[\\{\\}\\]: \\{\\}","errorType":"exception","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/commitlog/src/repo/mod.rs","lineNumber":473,"sourceCode":"\n/// Obtain the canonical [CompressOnce] compressor for segments.\n///\n/// The compressor will create seekable [Zstd] archives with a max frame size\n/// of 4KiB. That is, seeking to an arbitrary byte offset (of the uncompressed\n/// segment) within the archive will decompress 4KiB of data on average.\npub fn segment_compressor() -> Zstd {\n    Zstd {\n        max_frame_size: Some(0x1000),\n    }\n}\n\nfn segment_label<R: Repo>(repo: &R, offset: u64) -> String {\n    repo.segment_file_path(offset)\n        .unwrap_or_else(|| format!(\"offset {offset}\"))\n}\n\nfn with_segment_context<R: Repo>(context: &'static str, repo: &R, offset: u64, source: io::Error) -> io::Error {\n    io::Error::new(\n        source.kind(),\n        format!(\"{} [{}]: {}\", segment_label(repo, offset), context, source),\n    )\n}\n\n/// Allocate [Options::max_segment_size] of space for [FileLike]\n/// if the `fallocate` feature is enabled,\n/// and [Options::preallocate_segments] is `true`.\n///\n/// No-op otherwise.\n#[inline]\npub(crate) fn fallocate(_f: &mut impl FileLike, _opts: &Options) -> io::Result<()> {\n    #[cfg(feature = \"fallocate\")]\n    if _opts.preallocate_segments {\n        _f.fallocate(_opts.max_segment_size)?;\n    }\n\n    Ok(())","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/3653d2ed498fddbd83b7062aa6bf8970e18635ec/crates/commitlog/src/repo/mod.rs#L455-L491","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn segment_context_of(err: &io::Error) -> Option<(&str, &str)> {\n    // shape: '<label> [<context>]: <source>'\n    let msg = err.to_string();\n    let (head, source) = msg.split_once(\": \")?;\n    let context = head.rsplit_once(\" [\")?.1.strip_suffix(']')?;\n    Some((context, source))\n}","tryCatchPattern":"match repo.open_segment_reader(offset) {\n    Ok(r) => Ok(r),\n    Err(e) => {\n        if let Some((context, source)) = segment_context_of(&e) {\n            tracing::error!(segment = offset, context, source, kind = ?e.kind(), \"segment io failed\");\n        }\n        // dispatch on the preserved kind, not the wrapper text\n        match e.kind() {\n            io::ErrorKind::NotFound => /* file gone: restore or skip */,\n            _ => return Err(e),\n        }\n    }\n}","preventionTips":["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"],"tags":["rust","commitlog","error-context","io-error"],"backgroundTag":"error-context-chaining","analyzedSha":"3653d2ed498fddbd83b7062aa6bf8970e18635ec","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}