Skip to content

Commit

Permalink
chore: always fallback to legacy get pieces (#1180)
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Ma <[email protected]>
  • Loading branch information
jim3ma authored Mar 23, 2022
1 parent a3b0da4 commit f448a15
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit f448a15

Please sign in to comment.