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

[query] Fanout options to select namespaces #1328

Merged
merged 11 commits into from
Jan 31, 2019
Merged

Conversation

arnikola
Copy link
Collaborator

No description provided.

@arnikola arnikola changed the title R/add fanout option [query] Fanout options to select namespaces Jan 30, 2019
@codecov
Copy link

codecov bot commented Jan 30, 2019

Codecov Report

Merging #1328 into master will decrease coverage by 0.2%.
The diff coverage is 83.1%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 80.9% <ø> (-0.6%) ⬇️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.6% <ø> (-0.4%) ⬇️
#m3em 73.2% <ø> (ø) ⬆️
#m3ninx 74.7% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.8% <ø> (ø) ⬆️
#msg 74.9% <ø> (-0.2%) ⬇️
#query 64% <83.1%> (-0.4%) ⬇️
#x 75.9% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c85f85...fbe2219. Read the comment docs.

@codecov
Copy link

codecov bot commented Jan 30, 2019

Codecov Report

Merging #1328 into master will increase coverage by <.1%.
The diff coverage is 81.2%.

Impacted file tree graph

@@           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
Flag Coverage Δ
#aggregator 81.4% <ø> (ø) ⬆️
#cluster 85.6% <ø> (ø) ⬆️
#collector 78.4% <ø> (ø) ⬆️
#dbnode 80.9% <ø> (-0.1%) ⬇️
#m3em 73.2% <ø> (ø) ⬆️
#m3ninx 74.7% <ø> (ø) ⬆️
#m3nsch 51.1% <ø> (ø) ⬆️
#metrics 17.8% <ø> (ø) ⬆️
#msg 74.9% <ø> (-0.2%) ⬇️
#query 64.2% <81.2%> (+0.2%) ⬆️
#x 75.9% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c85f85...077d2c6. Read the comment docs.

fetchOptions.FanoutOptions = &storage.FanoutOptions{
FanoutUnaggregated: storage.FanoutForceDisable,
FanoutAggregated: storage.FanoutForceEnable,
FanoutAggregatedOptimized: storage.FanoutForceEnable,
Copy link
Collaborator

@robskillington robskillington Jan 30, 2019

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?

unaggregated ClusterNamespace
retention time.Duration
enabled bool
}
Copy link
Collaborator

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
Copy link
Collaborator Author

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,
Copy link
Collaborator

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?

Copy link
Collaborator Author

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 {
Copy link
Collaborator

@robskillington robskillington Jan 31, 2019

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?

Copy link
Collaborator Author

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,
Copy link
Collaborator

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 {
Copy link
Collaborator

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 {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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) {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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 {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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 {
Copy link
Collaborator

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(...).

@@ -52,6 +53,7 @@ type queryFanoutType uint
const (
namespaceCoversAllQueryRange queryFanoutType = iota
namespaceCoversPartialQueryRange
namespaceInvalid
Copy link
Collaborator

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?

Copy link
Collaborator Author

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,
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

Copy link
Collaborator

@robskillington robskillington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arnikola arnikola merged commit 806e93b into master Jan 31, 2019
@arnikola arnikola deleted the r/add-fanout-option branch January 31, 2019 15:49
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.

2 participants