casbin-redis-watcher
casbin-redis-watcher copied to clipboard
Watcher has severe data race problem
When I run the test, I found out it stuck, so I run it with flag --race, and there's severe data race problem
WARNING: DATA RACE
Read at 0x00c000118a70 by goroutine 21:
github.com/rafaeljusto/redigomock.match()
/home/closetool/go/pkg/mod/github.com/rafaeljusto/[email protected]/command.go:64 +0x2fa
github.com/rafaeljusto/redigomock.(*Conn).find()
/home/closetool/go/pkg/mod/github.com/rafaeljusto/[email protected]/redigomock.go:108 +0xe6
github.com/rafaeljusto/redigomock.(*Conn).do()
/home/closetool/go/pkg/mod/github.com/rafaeljusto/[email protected]/redigomock.go:163 +0x96
github.com/rafaeljusto/redigomock.(*Conn).Do()
/home/closetool/go/pkg/mod/github.com/rafaeljusto/[email protected]/redigomock.go:153 +0x131
github.com/billcobbler/casbin-redis-watcher/v2.(*testConn).Do()
<autogenerated>:1 +0x8f
github.com/billcobbler/casbin-redis-watcher/v2.(*Watcher).Update()
/home/closetool/tasks/go-tasks/casbin-redis-watcher/watcher.go:150 +0x1ec
github.com/casbin/casbin/v2.(*Enforcer).SavePolicy()
/home/closetool/go/pkg/mod/github.com/casbin/casbin/[email protected]/enforcer.go:298 +0x13b
github.com/billcobbler/casbin-redis-watcher/v2.TestWithEnforcerIgnoreSelf()
/home/closetool/tasks/go-tasks/casbin-redis-watcher/watcher_test.go:232 +0x14f9
testing.tRunner()
/usr/lib/go/src/testing/testing.go:1194 +0x202
Previous write at 0x00c000118a70 by goroutine 23:
github.com/billcobbler/casbin-redis-watcher/v2.(*Watcher).subscribe()
/home/closetool/tasks/go-tasks/casbin-redis-watcher/watcher.go:271 +0x124
github.com/billcobbler/casbin-redis-watcher/v2.NewWatcher.func1()
/home/closetool/tasks/go-tasks/casbin-redis-watcher/watcher.go:98 +0x188
Goroutine 21 (running) created at:
testing.(*T).Run()
/usr/lib/go/src/testing/testing.go:1239 +0x5d7
testing.runTests.func1()
/usr/lib/go/src/testing/testing.go:1512 +0xa6
testing.tRunner()
/usr/lib/go/src/testing/testing.go:1194 +0x202
testing.runTests()
/usr/lib/go/src/testing/testing.go:1510 +0x612
testing.(*M).Run()
/usr/lib/go/src/testing/testing.go:1418 +0x3b3
main.main()
_testmain.go:51 +0x236
Goroutine 23 (running) created at:
github.com/billcobbler/casbin-redis-watcher/v2.NewWatcher()
/home/closetool/tasks/go-tasks/casbin-redis-watcher/watcher.go:90 +0x41b
github.com/billcobbler/casbin-redis-watcher/v2.TestWithEnforcerIgnoreSelf()
/home/closetool/tasks/go-tasks/casbin-redis-watcher/watcher_test.go:208 +0xd64
testing.tRunner()
/usr/lib/go/src/testing/testing.go:1194 +0x202
==================
@hsluoyz
@billcobbler