-
Notifications
You must be signed in to change notification settings - Fork 453
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
[query] Fanout options to select namespaces #1328
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1328 +/- ##
========================================
- Coverage 70.7% 70.4% -0.3%
========================================
Files 814 811 -3
Lines 69314 69008 -306
========================================
- Hits 49005 48647 -358
- Misses 17181 17237 +56
+ Partials 3128 3124 -4
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #1328 +/- ##
========================================
+ Coverage 70.5% 70.6% +<.1%
========================================
Files 816 815 -1
Lines 69452 69363 -89
========================================
- Hits 49033 49006 -27
+ Misses 17291 17228 -63
- Partials 3128 3129 +1
Continue to review full report at Codecov.
|
fetchOptions.FanoutOptions = &storage.FanoutOptions{ | ||
FanoutUnaggregated: storage.FanoutForceDisable, | ||
FanoutAggregated: storage.FanoutForceEnable, | ||
FanoutAggregatedOptimized: storage.FanoutForceEnable, |
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.
I think we want this to be FanoutForceDisable
for the optimized flag so that all aggregated namespaces look like "partial" namespaces?
src/query/storage/m3/storage.go
Outdated
unaggregated ClusterNamespace | ||
retention time.Duration | ||
enabled bool | ||
} |
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.
Maybe move this type to top of this file?
@@ -57,5 +57,3 @@ t=$(date +%s) | |||
echo "foo.min.catch-all.baz 10 $t" | nc 0.0.0.0 7204 | |||
echo "foo.min.catch-all.baz 20 $t" | nc 0.0.0.0 7204 | |||
echo "Attempting to read mean aggregated carbon metric" | |||
ATTEMPTS=10 TIMEOUT=1 retry_with_backoff read_carbon foo.min.catch-all.baz 15 |
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.
Accidentally deleted
if unaggregatedStart.Before(start) || unaggregatedStart.Equal(start) { | ||
return unaggregatedNamespaceDetails{ | ||
clusterNamespace: unaggregated, | ||
satisfies: fullySatisfiesRange, |
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.
nit: Is it worth including retention
in return for this code path? In case it's needed in future and we don't find out that it's set to zero with tests or something?
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.
Sure, sounds good.
// | ||
// NB: if fanout aggregation is forced on, the filter instead forces clusters | ||
// that do not cover the range to be set as partially aggregated. | ||
filterFunc := func(namespace ClusterNamespace) bool { |
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.
nit: Maybe we call this coversRangeFilter
to declare intent of the filter in later code?
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.
Good call.
fetchOptions := storage.NewFetchOptions() | ||
fetchOptions.FanoutOptions = &storage.FanoutOptions{ | ||
FanoutUnaggregated: storage.FanoutForceDisable, | ||
FanoutAggregated: storage.FanoutForceEnable, |
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.
Hm, should we specifying Default perhaps here?
|
||
// No need to regenerate aggregated namespace without a filter if aggregated | ||
// fanout is force enabled. | ||
if opts.FanoutAggregated != storage.FanoutForceEnable { |
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.
Hm isn't the default to enable fanning out to aggregated namespaces in general?
i.e. if ForceEnable
and Default
should both always return aggregated namespaces, and for FanoutAggregatedOptimized
that should just determine whether to include or not include namespaces with downsampleOpts.All
into the complete or partial bucket.
So I would've thought for opts.FanoutAggregated == FanoutForceDisable
we would just always return the unaggregated namespace, and no namespaces if there is no unaggregated namespace at all. And then we shouldn't check this flag any later I would've thought?
result := r.partialAggregated | ||
// If unaggregated namespace can partially satisfy this range, add it as a | ||
// fanout contender. | ||
if unaggregated.satisfies == partiallySatisfiesRange { |
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.
Is this check necessary? If it fully satisifies the query range it would've already be returned on line 87 as part of the first check no?
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.
Yeah, it's to check that it's not disabled
here... I didn't want to use two bools like enabled, coversRange bool
since they're kinda linked
// range, set query fanout type to namespaceCoversPartialQueryRange. | ||
for _, n := range result { | ||
clusterStart := now.Add(-1 * n.Options().Attributes().Retention) | ||
if clusterStart.After(start) { |
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.
Unfortunately you need to do clusterStart.Equal(..) || clusterStart.After(...)
to take into account the case where the start and cluster start is an exact match.
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.
Ah damn I thought I flipped it to !clusterStart.Before(..)
slices = slices.reset(len(all)) | ||
|
||
// Force disable fanout to any aggregated namespaces. | ||
if opts.FanoutAggregated == storage.FanoutForceDisable { |
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.
As discussed before, if FanoutAggregated
is actually disabled, then we can just probably return immediately after checking the unaggregated namespace. (i.e. return unaggregated as long as that is default or enabled) and then don't need to check it again at all.
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.
Yeah, it gets to the same conclusion but with more steps; will try and short circuit it instead
} | ||
|
||
// If fanout is forced, ignore the filter. | ||
if opts.FanoutAggregated != storage.FanoutForceEnable { |
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.
I was thinking we would not actually need to skip the check here, since if FanoutAggregatedOptimized
is forced disabled, then you'll always run this function with filter == nil
because you won't take the path of if len(r.completeAggregated) > 0
after running the first call to aggregatedNamespaces(...)
.
src/query/storage/m3/storage.go
Outdated
@@ -52,6 +53,7 @@ type queryFanoutType uint | |||
const ( | |||
namespaceCoversAllQueryRange queryFanoutType = iota | |||
namespaceCoversPartialQueryRange | |||
namespaceInvalid |
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.
nit: Maybe make this the first value in the enum?
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.
That may cause errors later which would be hard to track? This is more used as just an invalid 'nil'ish value, still makes more sense to put it as first value?
|
||
if opts.FanoutAggregated == storage.FanoutForceDisable { | ||
if unaggregated.satisfies == partiallySatisfiesRange { | ||
return namespaceCoversAllQueryRange, |
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.
nit: Probably better to return namespaceCoversPartialQueryRange
here since it only partially satisfies the range?
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.
Nice catch
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
No description provided.