apache/cassandra · error · InvalidRequestException
Invalid paging state.
Error message
Invalid paging state.
What it means
DescribeStatement (DESCRIBE output for schema/tables/etc.) deserializes the client-supplied PagingState blob to continue pagination; if the blob cannot be decoded (DataInputStream/ByteArrayInputStream I/O failure), it throws InvalidRequestException('Invalid paging state.').
Solutions
- Restart pagination from the beginning (null paging state) instead of reusing an opaque/incompatible state.
- Only pass PagingState values returned by the exact same statement type on a compatible Cassandra version.
- Don't mutate, truncate, or base64-round-trip the paging state bytes incorrectly; if persisting, store the raw bytes verbatim.
- Catch InvalidRequestException and fall back to a fresh first-page query.
Example fix
// before
state = oldStateFromOtherCommand; // incompatible blob
result = session.execute(describeStatement.setPagingState(state));
// after
try {
result = session.execute(describeStatement.setPagingState(savedState));
} catch (InvalidRequestException e) {
result = session.execute(describeStatement); // restart from page 1
} Defensive patterns
Strategy: try-catch
Validate before calling
// only reuse paging states obtained from the same statement type/version
if (savedState == null || savedState.remaining <= 0 || !savedState.sourceCommand.equals("DESCRIBE")) savedState = null; Type guard
boolean isValidPagingState(byte[] b) { return b != null && b.length > 0 && b.length <= 65535; } Try / catch
try { rs = session.execute(stmt.setPagingState(savedState)); } catch (InvalidRequestException e) { if (e.getMessage().equals("Invalid paging state.")) { rs = session.execute(stmt); /* restart from first page */ } else throw e; } Prevention
- Never hand-build or truncate PagingState bytes
- Persist paging state as exact raw bytes (lossless encoding)
- Restart pagination from scratch after client/server upgrades
When it happens
Trigger: Passing a PagingState produced by a different statement/version, a truncated or hand-crafted byte buffer, or one whose internal format doesn't match the current reader, causing an IOException during getPagingState's readUTF/readInt sequence.
Common situations: Client code persisting paging state across process restarts with a different Cassandra version; copying pagingState bytes between different DESCRIBE commands; truncating the byte buffer; driver-level manipulation of the state blob.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- A storage-attached index cannot be created over multiple…
- A TTL must be greater or equal to 0, but was
- Accord transaction uses dropped tables
- All arguments must have the same vector dimensions
- Attempted to delete an element from a list which is null
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/61f3f247122af156.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/cql3/statements/DescribeStatement.java:218
protected abstract List<ColumnSpecification> metadata(ClientState state);
private PagingState getPagingState(long nextPageOffset, UUID schemaVersion)
{
try (DataOutputBuffer out = new DataOutputBuffer())
{
out.writeShort(PAGING_STATE_VERSION);
out.writeUTF(FBUtilities.getReleaseVersionString());
out.write(UUIDGen.decompose(schemaVersion));
out.writeLong(nextPageOffset);
return new PagingState(out.asNewBuffer(),
null,
Integer.MAX_VALUE,
Integer.MAX_VALUE);
}
catch (IOException e)
{
throw new InvalidRequestException("Invalid paging state.", e);
}
}
private long getOffset(PagingState pagingState, UUID schemaVersion)
{
if (pagingState == null)
return 0L;
try (DataInputBuffer in = new DataInputBuffer(pagingState.partitionKey, false))
{
checkTrue(in.readShort() == PAGING_STATE_VERSION, "Incompatible paging state");
final String pagingStateServerVersion = in.readUTF();
final String releaseVersion = FBUtilities.getReleaseVersionString();
checkTrue(pagingStateServerVersion.equals(releaseVersion),
"The server version of the paging state %s is different from the one of the server %s",
pagingStateServerVersion,
releaseVersion);View on GitHub (pinned to 88fd0f6a0e)