apache/cassandra · error · IllegalArgumentException
Unable to seek to position
Error message
Unable to seek to position %d in %s (%d bytes) in partial mode
What it means
EncryptedFileSegmentInputStream.seek(position) in partial mode computes a buffer position within the current decrypted chunk. If the resulting bufferPos is negative or exceeds the chunk capacity, the requested position is unreachable in the loaded chunk and IllegalArgumentException is thrown. This happens when replay tries to seek past the readable (decrypted/partial) region of an encrypted commit log segment.
Solutions
- Restore the full encrypted segment file and its encryption key / KMIP access.
- Verify commit log encryption settings (transparent_data_encryption_options) match those used when the segment was written.
- Accept partial replay by dropping the damaged segment and repairing data via nodetool repair.
- Check that the file wasn't truncated during backup/restore (compare sizes with source).
Defensive patterns
Strategy: validation
Validate before calling
if (position > segmentOffset + expectedLength)
throw new IllegalArgumentException("Seek beyond encrypted segment length"); Try / catch
try {
reader.seek(pos);
} catch (IllegalArgumentException e) {
logger.error("Encrypted commitlog seek failed (truncation or key mismatch): {}", e.getMessage());
} Prevention
- Ensure encryption keys/KMIP used at write time remain available at replay
- Keep transparent_data_encryption_options consistent between writer and replayer
- Verify restored encrypted files were not truncated (size comparison)
When it happens
Trigger: Seeking to an offset beyond segmentOffset + expectedLength or into a region whose chunk could not be decrypted/loaded, e.g. replaying a truncated encrypted segment or one encrypted with different key/provider settings.
Common situations: Commit log encrypted with transparent data encryption keys that were rotated/lost; truncated encrypted segment restored from partial backup; replaying a segment while its length metadata disagrees with actual ciphertext.
Understand the failure class
Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.
Related errors
- commitlog_disk_access_mode =
- could not read encrypted blocked metadata header
- Encountered bad header at position
- Encountered bad header at position
- failed to decrypt commit log block
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/547d537c8b6c5705.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/db/commitlog/EncryptedFileSegmentInputStream.java:90
public long bytesRemaining()
{
return expectedLength - (totalChunkOffset + buffer.position());
}
public void seek(long position)
{
long bufferPos = position - totalChunkOffset - segmentOffset;
while (buffer != null && bufferPos > buffer.capacity())
{
// rebuffer repeatedly until we have reached desired position
buffer.position(buffer.limit());
// increases totalChunkOffset
reBuffer();
bufferPos = position - totalChunkOffset - segmentOffset;
}
if (buffer == null || bufferPos < 0 || bufferPos > buffer.capacity())
throw new IllegalArgumentException(
String.format("Unable to seek to position %d in %s (%d bytes) in partial mode",
position,
getPath(),
segmentOffset + expectedLength));
buffer.position((int) bufferPos);
}
public long bytesPastMark(DataPosition mark)
{
throw new UnsupportedOperationException();
}
public void reBuffer()
{
totalChunkOffset += buffer.position();
buffer = chunkProvider.nextChunk();
}
}View on GitHub (pinned to 88fd0f6a0e)