Skip to content

Watcher has severe data race problem #23

@kilosonc

Description

@kilosonc

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/redigomock@v0.0.0-20170720131524-7ae0511314e9/command.go:64 +0x2fa
  github.com/rafaeljusto/redigomock.(*Conn).find()
      /home/closetool/go/pkg/mod/github.com/rafaeljusto/redigomock@v0.0.0-20170720131524-7ae0511314e9/redigomock.go:108 +0xe6
  github.com/rafaeljusto/redigomock.(*Conn).do()
      /home/closetool/go/pkg/mod/github.com/rafaeljusto/redigomock@v0.0.0-20170720131524-7ae0511314e9/redigomock.go:163 +0x96
  github.com/rafaeljusto/redigomock.(*Conn).Do()
      /home/closetool/go/pkg/mod/github.com/rafaeljusto/redigomock@v0.0.0-20170720131524-7ae0511314e9/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/v2@v2.1.0/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
==================

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