-
Notifications
You must be signed in to change notification settings - Fork 719
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
config: fix goroutine leak risk #3091
Conversation
Signed-off-by: Song Gao <disxiaofei@163.com>
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.
LGTM
/merge |
/run-all-tests |
@@ -35,6 +35,7 @@ import ( | |||
type PersistOptions struct { | |||
// configuration -> ttl value | |||
ttl map[string]*cache.TTLString | |||
ttlCancel map[string]context.CancelFunc |
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 create cache.TTLString
for each key, instead of use only 1 cache.TTLString
for all keys?
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.
For each configuration, they could have different ttl.
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-4.0 in PR #3094 |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com> Co-authored-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao disxiaofei@163.com
What problem does this PR solve?
What is changed and how it works?
The
SetTTLData
may have goroutine leak asNewStringTTL
would create an extra goroutine to do the gc work. When updating an existed key, we need to call the cancel function to close the extra goroutine.As the origin context is directly use the server context, this request fix it by replace a new context which is success from the server context and maintained its cancel function.
Release note