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

sync -- add handling for fatal error #1690

Merged
merged 41 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
737d4d0
comment nits
Jul 3, 2023
accde38
comment nits
Jul 3, 2023
8beeb86
Error --> Warn log
Jul 3, 2023
2dd784d
nits
Jul 3, 2023
c68b57c
change order of return values in get
Jul 3, 2023
c6d57c4
remove sleep
Jul 3, 2023
17235ad
comment nits
Jul 3, 2023
49a9f16
comment nits
Jul 3, 2023
2b52ab3
clean up tracking of outstanding requests
Jul 3, 2023
a6ae3a5
comment
Jul 3, 2023
a852001
revert error changes
Jul 3, 2023
b17c2fe
simplify client get loop (#1681)
darioush Jul 3, 2023
81f9dbc
nit
Jul 3, 2023
9b3b955
`sync` -- add exponential backoff (#1684)
Jul 3, 2023
b8e99ff
unexport stuff
Jul 3, 2023
32bb544
unexport stuff
Jul 3, 2023
43912de
more export changes
Jul 3, 2023
62996e3
unexport client
Jul 3, 2023
8202366
nit
Jul 5, 2023
3f641c5
Merge branch 'sync-refactor-client' into sync-refactor-client-unexport
Jul 5, 2023
82e242d
typo
Jul 5, 2023
264f143
switch return value order for RequestAny
Jul 5, 2023
dc8f887
Merge branch 'sync-refactor-client' into sync-refactor-client-unexport
Jul 5, 2023
e55ae21
add handling for fatal error
Jul 5, 2023
9cb255e
comment nits
Jul 5, 2023
1d75906
fix client range proof tests
Jul 5, 2023
816426e
fix change proof tests
Jul 6, 2023
325e48f
Merge branch 'dev' into sync-refactor-client
Jul 6, 2023
1967344
Merge remote-tracking branch 'upstream/dev' into sync-refactor-client…
Jul 6, 2023
5ea4efc
add test
Jul 6, 2023
0b0f248
Merge remote-tracking branch 'upstream/dev' into sync-refactor-client
Jul 6, 2023
96d3118
Merge branch 'sync-refactor-client' of github.com:ava-labs/avalancheg…
Jul 6, 2023
c39e6cd
Merge branch 'sync-refactor-client' into sync-refactor-client-error-h…
Jul 6, 2023
8c1db70
Merge branch 'sync-refactor-client' into sync-refactor-client-unexport
Jul 6, 2023
2381cc9
Merge branch 'sync-refactor-client-unexport' into sync-refactor-clien…
Jul 6, 2023
e1dd22d
comment
Jul 6, 2023
08af0b2
Merge remote-tracking branch 'upstream/dev' into sync-refactor-client…
Jul 14, 2023
6cb8674
Merge remote-tracking branch 'upstream/dev' into sync-refactor-client…
Aug 1, 2023
2d8d200
fix unit test
Aug 1, 2023
89825d5
Merge remote-tracking branch 'upstream/dev' into sync-refactor-client…
Aug 9, 2023
01d9862
Merge remote-tracking branch 'upstream/dev' into sync-refactor-client…
Aug 9, 2023
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
12 changes: 10 additions & 2 deletions x/sync/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,13 @@ type ClientConfig struct {
}

func NewClient(config *ClientConfig) Client {
c := &client{
return &client{
networkClient: config.NetworkClient,
stateSyncNodes: config.StateSyncNodeIDs,
stateSyncMinVersion: config.StateSyncMinVersion,
log: config.Log,
metrics: config.Metrics,
}
return c
}

// GetChangeProof synchronously retrieves the change proof given by [req].
Expand Down Expand Up @@ -196,6 +195,8 @@ func (c *client) GetRangeProof(ctx context.Context, req *pb.SyncGetRangeProofReq
// [parseFn] parses the raw response.
// If the request is unsuccessful or the response can't be parsed,
// retries the request to a different peer until [ctx] expires.
// Returns [errAppRequestSendFailed] if we fail to send an AppRequest.
// This should be treated as a fatal error.
func getAndParse[T any](
ctx context.Context,
client *client,
Expand All @@ -215,6 +216,11 @@ func getAndParse[T any](
}
}

if errors.Is(err, errAppRequestSendFailed) {
// Failing to send an AppRequest is a fatal error.
return nil, err
}

client.log.Debug("request failed, retrying",
zap.Stringer("nodeID", nodeID),
zap.Int("attempt", attempt),
Expand Down Expand Up @@ -249,6 +255,8 @@ func getAndParse[T any](
// until the node receives a response, failure notification
// or [ctx] is canceled.
// Returns the peer's NodeID and response.
// Returns [errAppRequestSendFailed] if we failed to send an AppRequest.
// This should be treated as fatal.
// It's safe to call this method multiple times concurrently.
func (c *client) get(ctx context.Context, request []byte) (ids.NodeID, []byte, error) {
var (
Expand Down
Loading