Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Results of GC are not processed #440

Open
Benevor opened this issue Feb 14, 2023 · 2 comments
Open

Results of GC are not processed #440

Benevor opened this issue Feb 14, 2023 · 2 comments

Comments

@Benevor
Copy link

Benevor commented Feb 14, 2023

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
}
@Connor1996
Copy link
Collaborator

It's only used in tests, and the test always init the channel at first.

@Benevor
Copy link
Author

Benevor commented Feb 22, 2023

It's only used in tests, and the test always init the channel at first.

Thank you for your reply. I found that in line 282 of the file kv/raftstore/raftstore. go, the raftLogGCTaskHandler was used again, and the pipeline was not initialized in advance. When we complete the code in project 2c and run the corresponding tests, the program will also enter the member function of the raftLogGCTaskHandler for execution. And I think it is unsafe to update LastCompletedIdx asynchronously, and submitted a pr to try to fix it. #441

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants