Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
fix gc bug
Browse files Browse the repository at this point in the history
Signed-off-by: yunfeiyangbuaa <yunfeiyang@buaa.edu.cn>
  • Loading branch information
yunfeiyanggzq committed Sep 23, 2019
1 parent 3846c51 commit 7609dc7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions supernode/daemon/mgr/gc/gc_dfget_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ import (
func (gcm *Manager) gcDfgetTasksWithTaskID(ctx context.Context, taskID string, cids []string) []error {
var errSlice []error
for _, cid := range cids {
// NOTE: At present, we create a peer for every dfgetTask.
// So we should also delete the peer when the dfgetTask deleted.
// In addition,if a peer crashes when servers,we can gc it by this way
//
// TODO: In the future, we need a heartbeat mechanism to get the peer status and
// implement a one-to-many relationship between peers and dfgetTasks.
// For compatibility with older versions, we can perform different operations according to the version of peer.
dfgetTask, err := gcm.dfgetTaskMgr.Get(ctx, cid, taskID)
if err == nil {
gcm.progressMgr.UpdatePeerServiceDown(ctx, dfgetTask.PeerID)
} else {
errSlice = append(errSlice, errors.Wrapf(err, "failed to get dfgetTask by cid(%s)", cid))
}

if err := gcm.progressMgr.DeleteCID(ctx, cid); err != nil {
errSlice = append(errSlice, errors.Wrapf(err, "failed to delete dfgetTask(%s) progress info", cid))
}
Expand Down
1 change: 1 addition & 0 deletions supernode/daemon/mgr/gc/gc_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (gcm *Manager) gcPeers(ctx context.Context) {
peerState, err := gcm.progressMgr.GetPeerStateByPeerID(ctx, peerID)
if err != nil {
logrus.Warnf("gc peers: failed to get peerState peerID(%s): %v", peerID, err)
gcm.gcPeer(ctx, peerID)
continue
}

Expand Down

0 comments on commit 7609dc7

Please sign in to comment.