You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Guangcun Li (Jira)" <ji...@apache.org> on 2026/09/24 15:23:00 UTC

[jira] [Updated] (RATIS-2717) Incorrect size accounting in SegmentedRaftLogReader.decodeEntry()

     [ https://issues.apache.org/jira/browse/RATIS-2717?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Guangcun Li updated RATIS-2717:
-------------------------------
    Attachment: RATIS-2717_test.patch

> Incorrect size accounting in SegmentedRaftLogReader.decodeEntry()
> -----------------------------------------------------------------
>
>                 Key: RATIS-2717
>                 URL: https://issues.apache.org/jira/browse/RATIS-2717
>             Project: Ratis
>          Issue Type: Bug
>          Components: RaftLog
>            Reporter: Guangcun Li
>            Priority: Major
>         Attachments: RATIS-2717_test.patch
>
>
> h3. Incorrect size accounting in SegmentedRaftLogReader.decodeEntry()
> {{decodeEntry()}} checks the serialized entry size against {{{}maxOpSize{}}}, but also applies the same limit to reads that include the varint length prefix and the four-byte checksum.
> Let {{S}} be the serialized entry size and {{V}} the length-prefix size. A complete on-disk record occupies {{V + S + 4}} bytes.
>  * With {{{}maxOpSize = S{}}}, the entry-size check passes, but {{checkBufferSize(V + S, maxOpSize)}} fails with an {{{}IllegalStateException{}}}, which is wrapped in an {{{}IOException{}}}.
>  * With {{{}maxOpSize = V + S{}}}, the prefix and entry can be read, but reading the checksum exceeds the limit.
>  * With {{{}maxOpSize = V + S + 4{}}}, the same entry is read successfully.
> Account for the length prefix in the temporary-buffer bound, and for both the prefix and checksum in the read limit and mark range, while retaining the serialized-entry size check.
> h3. Verification
>  * A reproducing test writes a valid entry using {{SegmentedRaftLogOutputStream}} and verifies the three cases above.
>  * A regression test expecting a successful read with {{maxOpSize = S}} fails before the fix and passes after it.
>  * All six tests in {{TestRaftLogReadWrite}} pass with the fix in a focused javac/JUnit run.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)