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

carbonserver: fix a 404 related race condition in findCache #431

Merged
merged 1 commit into from
Oct 4, 2021

Conversation

bom-d-van
Copy link
Member

@bom-d-van bom-d-van commented Sep 30, 2021

The findCache logics doesnt handle 404 edge case well. When findCache is enabled,
if go-carbon receives multiple requests about the same query, only one
query is executed, other requests are put on-hold and wait until the leader
query execution is finished and returned the same result. When a query has no
matches, the leader request will return 404 but set no data for locked fellow
requests. This means other requests will see nil response and without errorNotFound.
For these requests, go-carbon will return 500 instead 404.
This has a negative impact on carbonapi, which might return users 200 for 404 (from go-carbon),
but 500 for 500 (from go-carbon).

This fix addresses the issue by setting an empty findResponse and check if file
count is 0 for response returned from findCache, and then return a proper 404
like the leader request.

The findCache logics doesnt handle 404 edge case well. When findCache is enabled,
if go-carbon receives multiple requests about the same query, only one
query is executed, other requests are put on-hold and wait until the leader
query execution is finished and returned the same result. When a query has no
matches, the leader request will return 404 but set no data for locked fellow
requests. This means other requests will see nil response and without errorNotFound.
For these requests, go-carbon will return 500 instead 404.
This has a negative impact on carbonapi, which might return users 200 for 404 (from go-carbon),
but 500 for 500 (from go-carbon).

This fix addresses the issue by setting an empty findResponse and check if file
count is 0 for response returned from findCache, and then return a proper 404
like the leader request.
@bom-d-van bom-d-van force-pushed the carbonserver/find-cache-racy-bug-fix branch from 0ee206a to a292bed Compare September 30, 2021 09:04
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

2 participants