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

added timewheel concurrency support #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

derkan
Copy link

@derkan derkan commented Nov 26, 2024

While removing a long list of items when they expire, godis fails because of concurrent use of map from following methods:

github.com/hdt3213/godis/lib/timewheel.(*TimeWheel).removeTask(...)
github.com/hdt3213/godis/lib/timewheel.(*TimeWheel).scanAndRunTask.func1()

This PR is aimed to resolve this issue #233.

Error log is:

fatal error: concurrent map read and map write
goroutine 10 [running]:
github.com/hdt3213/godis/lib/timewheel.(*TimeWheel).removeTask(...)
	/Users/erkan/go/pkg/mod/github.com/hdt3213/godis@v1.2.9/lib/timewheel/timewheel.go:170
github.com/hdt3213/godis/lib/timewheel.(*TimeWheel).start(0xc0000bcea0)
	/Users/erkan/go/pkg/mod/github.com/hdt3213/godis@v1.2.9/lib/timewheel/timewheel.go:97 +0x1ae
created by github.com/hdt3213/godis/lib/timewheel.(*TimeWheel).Start in goroutine 1
	/Users/erkan/go/pkg/mod/github.com/hdt3213/godis@v1.2.9/lib/timewheel/timewheel.go:64 +0x8a

....

goroutine 13896 [runnable]:
github.com/hdt3213/godis/lib/timewheel.(*TimeWheel).scanAndRunTask.func1()
	/Users/erkan/go/pkg/mod/github.com/hdt3213/godis@v1.2.9/lib/timewheel/timewheel.go:124
created by github.com/hdt3213/godis/lib/timewheel.(*TimeWheel).scanAndRunTask in goroutine 7122
	/Users/erkan/go/pkg/mod/github.com/hdt3213/godis@v1.2.9/lib/timewheel/timewheel.go:124 +0xb8

....

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

Successfully merging this pull request may close these issues.

1 participant