Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage: fill the reservation before sending the snapshot response #10440

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/storage/raft_transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package storage
import (
"bytes"
"fmt"
"io"
"net"
"sort"
"sync/atomic"
Expand Down Expand Up @@ -601,7 +602,7 @@ func (c snapshotClientWithBreaker) Send(m *SnapshotRequest) error {

func (c snapshotClientWithBreaker) Recv() (*SnapshotResponse, error) {
m, err := c.MultiRaft_RaftSnapshotClient.Recv()
if err != nil {
if err != nil && err != io.EOF {
c.breaker.Fail()
}
return m, err
Expand Down
7 changes: 7 additions & 0 deletions pkg/storage/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package storage
import (
"bytes"
"fmt"
"io"
"math"
"math/rand"
"runtime"
Expand Down Expand Up @@ -3087,6 +3088,12 @@ func sendSnapshot(
if err != nil {
return errors.Wrapf(err, "range=%s: remote failed to apply snapshot", header.RangeDescriptor.RangeID)
}
// NB: wait for EOF which ensures that all processing on the server side has
// completed (such as defers that might be run after the previous message was
// received).
if _, err := stream.Recv(); err != io.EOF {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather odd for two reasons 1. the resp is ignored, and 2. I imagine it would be part of a receiver loop

return errors.Errorf("range=%s: expected EOF, got %v", header.RangeDescriptor.RangeID, err)
}
switch resp.Status {
case SnapshotResponse_ERROR:
return errors.Errorf("range=%s: remote failed to apply snapshot for reason %s",
Expand Down