fix: delete peer's parent on PeerEventDownloadSucceeded event (#1085)

When a peer leaves, it calls scheduler's LeaveTask() interface to
notify scheduler that it's leaving. And LeaveTask() will re-schedule
all its children to find a new parent by calling ScheduleParent().

But some of this peer's children might be in PeerStateSucceeded
state, as they have finished downloading tasks from parent. So
ScheduleParent() on such children is pointless.

Let's delete peer's parent on PeerEventDownloadSucceeded event, so
its parent won't call ScheduleParent() on it again, when its parent
is leaving.

Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
This commit is contained in:
Eryu Guan 2022-02-23 13:49:14 +08:00 committed by Gaius
parent 1c9ffcd938
commit f56de57c01
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
1 changed files with 1 additions and 0 deletions

View File

@ -199,6 +199,7 @@ func NewPeer(id string, task *Task, host *Host) *Peer {
p.Task.BackToSourcePeers.Delete(p) p.Task.BackToSourcePeers.Delete(p)
} }
p.DeleteParent()
p.UpdateAt.Store(time.Now()) p.UpdateAt.Store(time.Now())
p.Log.Infof("peer state is %s", e.FSM.Current()) p.Log.Infof("peer state is %s", e.FSM.Current())
}, },