Skip to content

Results of GC are not processed #440

@Benevor

Description

@Benevor

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions