-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
When executing the project2c test, in the function startWorkers, when raftLogGCWorker is started, the taskResCh in raftLogGCTaskHandler is nil.
It caused collected not to be sent as expected in the function reportCollected.
type raftLogGCTaskHandler struct {
taskResCh chan<- raftLogGcTaskRes
}
func NewRaftLogGCTaskHandler() *raftLogGCTaskHandler {
return &raftLogGCTaskHandler{}
}
func (r *raftLogGCTaskHandler) reportCollected(collected uint64) {
if r.taskResCh == nil {
return
}
r.taskResCh <- raftLogGcTaskRes(collected)
}
Raftlog-gc worker does the actual log deletion work asynchronously. Since the result of GC has not been sent, when a certain RaftLogGCTask is not successfully processed, the LastCompactedIdx is still updated in the ScheduleCompactLog function. I think this may cause some logs to not be collected for a long time.
func (d *peerMsgHandler) ScheduleCompactLog(truncatedIndex uint64) {
raftLogGCTask := &runner.RaftLogGCTask{
RaftEngine: d.ctx.engine.Raft,
RegionID: d.regionId,
StartIdx: d.LastCompactedIdx,
EndIdx: truncatedIndex + 1,
}
d.LastCompactedIdx = raftLogGCTask.EndIdx
d.ctx.raftLogGCTaskSender <- raftLogGCTask
}
Metadata
Metadata
Assignees
Labels
No labels