vectordotdev/vector · error · io::Error
InvalidInput
InvalidInput
Error message
cannot extend a file through the truncation API
What it means
In the disk-buffer v2 writer, `truncate_current_data_file` applies a shrink to the current data file after flushing, and guards the invariant that the requested size must not exceed `writer.current_data_file_size`. Violating it returns `InvalidInput` "cannot extend a file through the truncation API". Because this runs after a writer-checkpoint scan (with the reader dropped for Windows compatibility), an oversized request indicates the writer's notion of the file size disagrees with the truncation target — an internal consistency failure, not normal operation.
Source
Thrown at lib/vector-buffers/src/variants/disk_v2/writer.rs:1241
WriterCheckpointScanAction::Continue => {}
WriterCheckpointScanAction::Stop => break,
}
}
}
}
// Windows does not permit truncating a file while the scan's read handle remains open.
drop(reader);
self.apply_writer_checkpoint_scan(scan).await
}
async fn truncate_current_data_file(&mut self, size: u64) -> io::Result<()> {
let writer = self
.writer
.as_mut()
.expect("writer should exist after `ensure_ready_for_write`");
if size > writer.current_data_file_size {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
"cannot extend a file through the truncation API",
));
}
writer.writer.flush().await?;
let data_file_path = self.ledger.get_current_writer_data_file_path();
self.ledger
.filesystem()
.truncate_file(&data_file_path, size)
.await?;
writer.current_data_file_size = size;
self.data_file_size = size;
Ok(())
}
View on GitHub (pinned to 3708c39b12)
Solutions
- If the buffer's on-disk state is suspect, move aside/delete the `data_dir` buffer directory and let Vector recreate it (accepted data loss of buffered events).
- Report upstream with the Vector version and buffer config if it reproduces on an untouched data directory — the size mismatch is an internal invariant break.
- Ensure only one Vector instance uses a given buffer directory and that versions are not interleaved across restarts.
Defensive patterns
Strategy: validation
Validate before calling
// Internal guard before requesting truncation:
if size > writer.current_data_file_size {
warn!(size, current = writer.current_data_file_size,
"skipping truncation that would extend the data file");
return Ok(());
} Prevention
- Keep buffer directories single-instance, single-version; never share or hand-edit them.
- If a buffer's state may be inconsistent after a crash, recreate the directory instead of forcing recovery.
- Report reproducible occurrences upstream — this path indicates an internal invariant break.
When it happens
Trigger: Buffer internals requesting truncation past the tracked data-file size — e.g. corrupted ledger/checkpoint state after a crash, manual tampering with the data directory, or a bug in offset arithmetic feeding `truncate_current_data_file`. Ordinary Vector users should never see this from config alone.
Common situations: Data-disk-buffer files edited/copied by hand; mixing buffer directories between Vector versions or instances; disk state mutated while Vector was stopped; bugs in buffer checkpoint recovery.
Related errors
- InvalidInput
- effective reader file ID must be in the checkpoint window
- record was already validated
- Event count for a record cannot exceed 2^64 events.
- a record with a next ID must have an event count
AI-assisted analysis of vectordotdev/vector@3708c39b12 (2026-08-20).
Data as JSON: /api/errors/f6b52ada9fe44b0b.
Report an issue: GitHub.