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

chore: always fallback to legacy get pieces #1180

Merged
merged 1 commit into from
Mar 23, 2022
Merged
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
6 changes: 4 additions & 2 deletions client/daemon/peer/peertask_piecetask_synchronizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@ func (s *pieceTaskSyncManager) newPieceTaskSynchronizer(
request.DstPid = dstPeer.PeerId
client, err := dfclient.SyncPieceTasks(ctx, dstPeer, request)
if err != nil {
s.peerTaskConductor.Errorf("call SyncPieceTasks error: %s, dest peer: %s", err, dstPeer.PeerId)
return err
}

// TODO the codes.Unimplemented is received only in client.Recv()
// when remove legacy get piece grpc, can move this check into synchronizer.receive
piecePacket, err := client.Recv()
if err != nil {
s.peerTaskConductor.Warnf("receive from SyncPieceTasksClient error: %s, dest peer: %s", err, dstPeer.PeerId)
_ = client.CloseSend()
return err
}
Expand Down Expand Up @@ -165,14 +167,14 @@ func (s *pieceTaskSyncManager) newMultiPieceTaskSynchronizer(
if err == nil {
continue
}
legacyPeers = append(legacyPeers, peer)
// when err is codes.Unimplemented, fallback to legacy get piece grpc
stat, ok := status.FromError(err)
if ok && stat.Code() == codes.Unimplemented {
legacyPeers = append(legacyPeers, peer)
s.peerTaskConductor.Warnf("connect peer %s error: %s, fallback to legacy get piece grpc", peer.PeerId, err)
} else {
s.reportError(peer)
s.peerTaskConductor.Errorf("connect peer %s error: %s, not codes.Unimplemented, did not fallback to legacy", peer.PeerId, err)
s.peerTaskConductor.Errorf("connect peer %s error: %s, not codes.Unimplemented", peer.PeerId, err)
}
}
s.cleanStaleWorker(destPeers)
Expand Down