From e6a474ead7f07bb268b2b90cd269fdf353b2b569 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 15 Aug 2016 23:20:34 +0100 Subject: [PATCH] fix report store query chaining We fell victim to variable shadowing here. Each store would be fed the original list of report keys, instead of only the ones that weren't found in the previous store. So if a single report was missing from the in-process cache, we would then fetch all reports from memcache. And if that in turn was missing a single report we would fetch all reports from S3. We chain report stores for a reason - to reduce latency and, in case of the in-process cache, eliminate decoding costs. So this bug has a huge impact on query service performance. To make matters worse, we return *all* the reports - now possibly in triplicate. Fortunately, the SmartMerger filters these out, so at least we were not incurring extra merge costs. --- app/multitenant/aws_collector.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/multitenant/aws_collector.go b/app/multitenant/aws_collector.go index 346b7ebb4..36f18da64 100644 --- a/app/multitenant/aws_collector.go +++ b/app/multitenant/aws_collector.go @@ -277,7 +277,8 @@ func (c *awsCollector) getReports(reportKeys []string) ([]report.Report, error) if store == nil { continue } - found, missing, err := store.FetchReports(missing) + found, newMissing, err := store.FetchReports(missing) + missing = newMissing if err != nil { log.Warningf("Error fetching from cache: %v", err) }