Skip to content

timewheel concurrency issue #233

@derkan

Description

@derkan

While removing a long list of times 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()

Added a PR #232 for concurrency
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

....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions