Skip to content

Read every received entry through the stream: an entry ending at the end of the sender's buffer is read through to its final frame - #310

Merged
sakno merged 4 commits into
dotnet:developfrom
galvesribeiro:fix-framing-final-frame
Nov 2, 2026
Merged

sakno merged 4 commits into
dotnet:developfrom
galvesribeiro:fix-framing-final-frame

Conversation

@galvesribeiro

@galvesribeiro galvesribeiro commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Fixes #308.

ProtocolStream.TryReadFrameData took an entry's payload in one go when its frame held it whole, even from a non-final frame. A payload that ends where the sender's buffer ended arrives in a full, non-final frame followed by an empty final frame, whose header was then left to be read as the next entry's metadata.

The method is removed: every received entry is read through the stream, which reads the final frame too. Its fast path saved a copy only when a payload came whole in one frame within the buffer, and with the write-ahead log copying into its own pages it saves nothing.

Test: TcpTransportTests.SendingLogEntriesAcrossFrames (the shared TransportTestSuite.SendingLogEntriesAcrossFramesTest) sends two entries for every first-entry size from 1 to 1000 bytes with a 400-byte block and checks both arrive as sent. Without the fix it fails with MemberUnavailableException at the size ending at the buffer's end.

…through the stream

Its fast path saved a copy only when an entry's payload came whole in a final frame that fit in the buffer, and with the write-ahead log copying into its own pages it saves nothing. It was also where an entry ending at the end of the sender's buffer went wrong, its empty final frame left to be read as the next entry's metadata.
@galvesribeiro galvesribeiro changed the title Read an entry ending at the end of the sender's buffer through to its final frame Read every received entry through the stream: an entry ending at the end of the sender's buffer is read through to its final frame Nov 2, 2026
@galvesribeiro

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 310 in repo dotnet/dotNext

@sakno
sakno merged commit bf913fe into dotnet:develop Nov 2, 2026
8 checks passed
@galvesribeiro
galvesribeiro deleted the fix-framing-final-frame branch November 2, 2026 17:00
@galvesribeiro

Copy link
Copy Markdown
Member Author

Hello @sakno! Can we get a release with this? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Lib:Cluster DotNext.Net.Cluster library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follower misreads the entry after one whose payload ends at the end of the leader's transmission buffer (term 0x80000000)

2 participants