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

Ch. 5 Race condition in counter.go #12

Closed
crbrox opened this issue Apr 9, 2015 · 3 comments
Closed

Ch. 5 Race condition in counter.go #12

crbrox opened this issue Apr 9, 2015 · 3 comments

Comments

@crbrox
Copy link
Contributor

crbrox commented Apr 9, 2015

I think that calling updater.Reset at https://github.com/matryer/goblueprints/blob/master/chapter5/counter/main.go#L98
causes a race condition

(the other access is at https://github.com/matryer/goblueprints/blob/master/chapter5/counter/main.go#L76)

@matryer
Copy link
Owner

matryer commented Apr 19, 2015

That's an interesting one. Are you sure it causes a race condition?

@crbrox
Copy link
Contributor Author

crbrox commented Apr 20, 2015

I think so ...

With build -race, this stack is displayed when counter is executed

2015/04/20 11:26:03 Finished updating database...
==================
WARNING: DATA RACE
Read by goroutine 23:
  main.func·004()
      /Users/brox/GoPath/src/github.com/matryer/goblueprints/chapter5/counter/main.go:98 +0x1f4

Previous write by main goroutine:
  main.main()
      /Users/brox/GoPath/src/github.com/matryer/goblueprints/chapter5/counter/main.go:99 +0xb3e

Goroutine 23 (running) created at:
  time.goFunc()
      /usr/local/go/src/time/sleep.go:129 +0x59
==================
2015/04/20 11:26:04 Updating database...

[...]

2015/04/20 11:29:19 INF    1 [votes/counter] stopping handlers
2015/04/20 11:29:19 INF    1 [votes/counter] exiting lookupdLoop
2015/04/20 11:29:19 INF    1 [votes/counter] rdyLoop exiting
2015/04/20 11:29:19 Closing database connection...
Found 1 data race(s)

@matryer
Copy link
Owner

matryer commented May 6, 2015

That's very interesting - thanks.

@matryer matryer closed this as completed Aug 16, 2015
@matryer matryer reopened this May 5, 2016
@matryer matryer closed this as completed Jul 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants