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

fix: concurrent write access #198

Merged
merged 1 commit into from
Jan 8, 2020

Conversation

Nazdroth
Copy link
Contributor

@Nazdroth Nazdroth commented Jan 8, 2020

While using bigcache today I encountered this error:

fatal error: concurrent map writes
goroutine 2487 [running]:
runtime.throw(0xe697aa, 0x15)
	/usr/local/go/src/runtime/panic.go:774 +0x72 fp=0xc5878dd388 sp=0xc5878dd358 pc=0x4310c2
runtime.mapassign_fast64(0xd1eec0, 0xc347b05bf0, 0x44b94351220b245d, 0xc5880a8000)
	/usr/local/go/src/runtime/map_fast64.go:176 +0x337 fp=0xc5878dd3c8 sp=0xc5878dd388 pc=0x413897
github.com/allegro/bigcache/v2.(*cacheShard).hit(0xc349c61560, 0x44b94351220b245d)

This bug was introduced by me 2 month ago instead of using Lock I used Rlock

@Nazdroth Nazdroth changed the title fix: concurent write access fix: concurrent write access Jan 8, 2020
@janisz
Copy link
Collaborator

janisz commented Jan 8, 2020

@Nazdroth thanks, how about enabling stats in test to prevent this bug in the future?

https://github.com/allegro/bigcache/blob/master/bigcache_test.go#L405-L406

@siennathesane
Copy link
Collaborator

I'm going to merge this change now to get the fix out, but I do agree stats should be enabled in the test suite.

@siennathesane siennathesane merged commit 035b28c into allegro:master Jan 8, 2020
janisz added a commit to janisz/bigcache that referenced this pull request Jan 8, 2020
cristaloleg pushed a commit that referenced this pull request Jan 8, 2020
flisky pushed a commit to flisky/bigcache that referenced this pull request May 7, 2020
flisky pushed a commit to flisky/bigcache that referenced this pull request May 7, 2020
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.

None yet

3 participants