-
Notifications
You must be signed in to change notification settings - Fork 102
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
Make the strict memory limit optional #61
base: master
Are you sure you want to change the base?
Make the strict memory limit optional #61
Conversation
Hmm, I don't think this PR does what you think it does — that |
Haha, you're totally right. I ended up trying to fix the wrong panic. It's actually this panic that we are running into regularly with errors like:
As I look at this problem again, I'm feeling more confused than I was before. Previously I was thinking we were running into a race condition, but I see that the caller of |
Yes, I can't see how that would manifest. Confusing. Would you be willing to try and reproduce with a bit more info added to the panic? - panic(fmt.Sprintf("%d bytes still won't fit in the cache! (max %d bytes)", valueSize, d.CacheSizeMax))
+ panic(fmt.Sprintf("%d bytes still won't fit in the cache! (current %d objects and %d bytes, max %d bytes)", valueSize, len(d.cache), d.cacheSize, d.CacheSizeMax)) |
I've adapted it to have an option to turn all of these panics into errors and am also adding more to the message so we can diagnose what's going on. |
I appreciate the pragmatism of the PR, but the panic is a panic and not an error for a reason :) as this condition appears to have identified a serious bug somewhere. edit: Oops, missed your second clause somehow. I'll wait for more details from you 👍 |
We have this deployed on consumer devices and it only happens infrequently. We don't have any steps to reproduce it. It's much better for us to eventually stop caching values and quietly return an error than it is to take down the process and stop working entirely. I agree that it appears there's a real bug here, but we need something to make it so that it doesn't crash, or stop using diskv entirely until we understand what the bug is. |
We would rather not have a
panic()
if the memory limit is exceeded due to concurrent access.This makes the panic optional.