PaginatedComponentFile.write/read ignore short-write / short-read returns (original) (raw)

Affected version: 26.4.2 (confirmed still present in 26.5.1)
Component: com.arcadedb.engine.PaginatedComponentFile

Summary

channel.write(ByteBuffer, long) and channel.read(ByteBuffer, long) are allowed to return fewer bytes than requested. ArcadeDB drops both return values and always returns pageSize from write(...).

Code

engine/com/arcadedb/engine/PaginatedComponentFile.java:136–202

public int write(final MutablePage page) throws IOException { … channel.write(buffer, (page.getPhysicalSize() * (long) pageNumber)); // return value dropped … return pageSize; }

public void read(final CachedPage page) throws IOException { … channel.read(buffer, page.getPhysicalSize() * (long) pageNumber); // return value dropped }

Impact

Under disk pressure (NFS, no space, slow flush, sparse-file quirks) a partially-written page is persisted without an error surfacing. The matching read() then loads a partial page and downstream consumers (CachedPage.loadMetadata silently clamps invalid sizes at line 66) accept truncated bytes.

Suggested fix

Loop until buffer.hasRemaining() == false, accumulating the returned counts.
Throw on -1 (EOF) or unexpected short read.