fix #3231 prevent snapshot corruption#3232
Open
nowheresly wants to merge 1 commit intomoby:masterfrom
Open
Conversation
Signed-off-by: Sylvere Richard <sylvere.richard@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
- What I did
Fixed snapshot corruption that occurs when the swarm state is large enough
that the raft message struct overhead exceeds GRPCMaxMsgSize.
- How I did it
Two fixes in manager/state/raft/transport/peer.go:
state causes the raft message struct overhead to exceed GRPCMaxMsgSize, the
computed payload size went negative, leading to corruption during snapshot
splitting. The payload size is now floored at 64 KiB to guarantee forward
progress.
loop was assigning sub-slices of Snapshot.Data directly through a shared
pointer, which mutated the original message's snapshot data across iterations.
Each chunk now gets its own copy of the Snapshot struct so the original data
remains intact for correct sub-slicing.
- How to test it
verifies both normal snapshots and the large-metadata scenario that previously
panicked/corrupted data.
TestRaftMessagePayloadSizeMinimum — verifies the payload size floor at 64 KiB.
- Description for the changelog
Fixes #3231 — prevent corruption of snapshot when swarm state is large. When
the raft message struct overhead exceeds the gRPC max message size (e.g.
clusters with many objects), snapshot splitting now clamps the chunk payload
to a minimum of 64 KiB and correctly copies the snapshot struct per chunk to
avoid data corruption.