carbonserver: fix a 404 related race condition in findCache #431
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.