-
Notifications
You must be signed in to change notification settings - Fork 599
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: panic when update and iterate simultaneously #232
Conversation
WideLee
commented
Jun 25, 2020
•
edited
Loading
edited
- Fix panic when update and iteration simultaneously. Related to Iterator readEntry crashes #222.
- Add panic recover in cleanUp to prevent the program exited. Related to panic: runtime error: index out of range [7] with length 1 #226, panic out of range in bytes queue #148, just protect the main program not exited.
- Byte queue set full is false after allocated addition memory. Also added a test case reproduce this problem.
1. Copy keys' hashed value instead of copy keys' index in ByteQueue. 2. Skip ErrNotFound during iteration when the key has been evicted.
shard.go
Outdated
@@ -253,6 +254,15 @@ func (s *cacheShard) onEvict(oldestEntry []byte, currentTimestamp uint64, evict | |||
} | |||
|
|||
func (s *cacheShard) cleanUp(currentTimestamp uint64) { | |||
defer func() { | |||
// panic recover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In #226 panic in cleanUp
.
If CleanWindows is not zero, bigcache starts a goroutine, if cleanUp panic, the whole program will be exited.
Lines 85 to 99 in bbbffd3
if config.CleanWindow > 0 { | |
go func() { | |
ticker := time.NewTicker(config.CleanWindow) | |
defer ticker.Stop() | |
for { | |
select { | |
case t := <-ticker.C: | |
cache.cleanUp(uint64(t.Unix())) | |
case <-cache.close: | |
return | |
} | |
} | |
}() | |
} | |
This is a temporary solution to prevent crash of whole program, actually, find out the reason why panic is important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks good to me, it could just use adjustments based off @janisz's comments.
Do you mean that I should rollback the commit about panic recover in |
This reverts commit 665c3a9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks okay to me. I wanted to take the panic recovery out because I want to see how much it's happening across the board and fix the root of the problem when it becomes a much larger issue.
Is there any progress on solving this underlying issue? We are still getting these crashes 🤦 |
@alexi you're still having this same issue? |
@mxplusb now getting this error:
|
@alexi can you please verify you are using this version or latest? |
@mxplusb Any idea when it might be merged? |
No ETA, we're prepping for v3, which should include a fix for this. I'll try and get some time spent on this soon. |
Any news, we have now the same issues on production servers (which we let crash and restart at the moment) |
Hey @mxplusb any update here? We are in the same boat as @fpessolano. If it's possible to deploy it as a smaller patch that would be very valuable. |
We're prepping for v3 in the |