-
Notifications
You must be signed in to change notification settings - Fork 9
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 issue where PostingsForMatchersCache
can cache a context cancellation error
#546
Fix issue where PostingsForMatchersCache
can cache a context cancellation error
#546
Conversation
Signed-off-by: Charles Korn <[email protected]>
…che. Signed-off-by: Charles Korn <[email protected]>
Signed-off-by: Arve Knudsen <[email protected]>
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; I had to fix postingsForMatcherPromise.result
, so it's deterministic and doesn't randomly fail tests.
…ache-context-cancellation Fix issue where `PostingsForMatchersCache` can cache a context cancellation error
promise = oldPromise.(*postingsForMatcherPromise) | ||
return promise.result | ||
// promise was not stored, we return a previously stored promise, that's possibly being fulfilled in another goroutine | ||
close(promise.done) |
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.
@aknuds1 why is closing the channel here necessary?
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.
@charleskorn I guess it was old habit, thinking that the unused channel should be closed, but thinking it through again, it's actually not necessary. It should make no difference for garbage collection, AFAIK.
…ache-context-cancellation Fix issue where `PostingsForMatchersCache` can cache a context cancellation error
…ache-context-cancellation Fix issue where `PostingsForMatchersCache` can cache a context cancellation error
If the initial request for a set of matchers to
PostingsForMatchersCache.PostingsForMatchers()
cancels its context before the call returns, this cancellation can be cached, causing all subsequent calls to the cache for the same matchers to also return a context cancellation error while the cache entry is still live.While this PR is sufficient to fix the problem above, there are some further improvements we could consider in the future:
PostingsForMatchersCache.PostingsForMatchers()
have cancelled their context, should we cancel the context passed to the underlyingPostingsForMatchers
implementation?