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] Add ClusterNamespacesWatcher and use to generate downsample automapper rules #2782

Merged
merged 3 commits into from
Oct 26, 2020

Conversation

nbroyles
Copy link
Collaborator

What this PR does / why we need it:

With the change to make the coordinator resolve namespaces dynamically, parts of the coordinator that expect to have all available namespaces on startup need to be updated. This PR adds a cluster namespaces watcher that parts of the coordinator can use to get notified of changes. It also updates the downsampler to make use of this watcher to generate automapping rules.

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:


Does this PR require updating code package or user-facing documentation?:


@codecov
Copy link

codecov bot commented Oct 23, 2020

Codecov Report

Merging #2782 into nb/use-staging-state will increase coverage by 5.1%.
The diff coverage is 41.9%.

Impacted file tree graph

@@                   Coverage Diff                   @@
##           nb/use-staging-state   #2782      +/-   ##
=======================================================
+ Coverage                  45.6%   50.7%    +5.1%     
=======================================================
  Files                         4    1013    +1009     
  Lines                       274   92663   +92389     
=======================================================
+ Hits                        125   47061   +46936     
- Misses                      139   41554   +41415     
- Partials                     10    4048    +4038     
Flag Coverage Δ
#aggregator 62.8% <ø> (?)
#cluster 62.6% <ø> (?)
#collector 62.3% <ø> (+16.7%) ⬆️
#dbnode 51.4% <95.0%> (?)
#m3em 46.2% <ø> (?)
#m3ninx 57.5% <ø> (?)
#m3nsch 78.0% <ø> (?)
#msg 73.2% <ø> (?)
#query 38.5% <19.7%> (?)
#x 48.1% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


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 9115e64...9214ce1. Read the comment docs.

Comment on lines +162 to +182
defaultStagedMetadatasProtos := make([]metricpb.StagedMetadatas, 0, len(autoMappingRules))
for _, rule := range autoMappingRules {
metadatas, err := rule.StagedMetadatas()
if err != nil {
logger.Error("could not generate staged metadata from automapping rules."+
" aggregations will continue with current configuration.", zap.Error(err))
return
}

var metadatasProto metricpb.StagedMetadatas
if err := metadatas.ToProto(&metadatasProto); err != nil {
logger.Error("could not generate staged metadata from automapping rules."+
" aggregations will continue with current configuration.", zap.Error(err))
return
}

defaultStagedMetadatasProtos = append(defaultStagedMetadatasProtos, metadatasProto)
}

d.Lock()
d.metricsAppenderOpts.defaultStagedMetadatasProtos = defaultStagedMetadatasProtos
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: it may be better to do this whole section under d.Lock() so that you can mutate d.metricsAppenderOpts.defaultStagedMetadatasProtos directly without needing the alloc on 162?

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, I think that only works if you end up with the same number of automapping rules after the update -- which is probably a corner case. Most likely, you'll have more automappings rules than before (as a result of a namespace addition) meaning we'd need re-size the existing one.

@nbroyles nbroyles force-pushed the nb/use-staging-state branch from 9115e64 to 8720ea2 Compare October 26, 2020 13:42
Copy link
Collaborator

@arnikola arnikola left a comment

Choose a reason for hiding this comment

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

LGTM w nits

@arnikola arnikola removed their assignment Oct 26, 2020
Base automatically changed from nb/use-staging-state to master October 26, 2020 14:28
@nbroyles nbroyles merged commit e15bc2c into master Oct 26, 2020
@nbroyles nbroyles deleted the nb/ns-watch branch October 26, 2020 14:54
soundvibe added a commit that referenced this pull request Oct 29, 2020
* master:
  Support dynamic namespace resolution for embedded coordinators (#2815)
  [dbnode] Add index regexp DFA compilation cache to avoid allocating DFAs for same expressions (#2814)
  [dbnode] Set default cache on retrieve to false, prepare testing with cache none (#2813)
  [tools] Output annotations as base64 (#2743)
  Add Reset Transformation (#2794)
  [large-tiles] Fix for a reverse index when querying downsampled namespace (#2808)
  [dbnode] Evict info files cache before index bootstrap in peers bootstrapper (#2802)
  [dbnode] Bump default filesystem persist rate limit (#2806)
  [coordinator] Add metrics and configurability of downsample and ingest writer worker pool (#2797)
  [dbnode] Fix concurrency granularity of seekerManager.UpdateOpenLease (#2790)
  [dbnode] Use correct import path for atomic library (#2801)
  Regenerate carbon automapping rules on namespaces changes (#2793)
  Enforce matching retention and index block size (#2783)
  [query] Add ClusterNamespacesWatcher and use to generate downsample automapper rules (#2782)
  [query][dbnode] Wire up etcd-backed Clusters implementation in coordinator (#2758)
  [query] Fix quantile() argument not being passed through (#2780)

# Conflicts:
#	src/query/parser/promql/matchers.go
soundvibe added a commit that referenced this pull request Oct 29, 2020
* master:
  [query] Improve precision for variance and stddev of equal values (#2799)
  Support dynamic namespace resolution for embedded coordinators (#2815)
  [dbnode] Add index regexp DFA compilation cache to avoid allocating DFAs for same expressions (#2814)
  [dbnode] Set default cache on retrieve to false, prepare testing with cache none (#2813)
  [tools] Output annotations as base64 (#2743)
  Add Reset Transformation (#2794)
  [large-tiles] Fix for a reverse index when querying downsampled namespace (#2808)
  [dbnode] Evict info files cache before index bootstrap in peers bootstrapper (#2802)
  [dbnode] Bump default filesystem persist rate limit (#2806)
  [coordinator] Add metrics and configurability of downsample and ingest writer worker pool (#2797)
  [dbnode] Fix concurrency granularity of seekerManager.UpdateOpenLease (#2790)
  [dbnode] Use correct import path for atomic library (#2801)
  Regenerate carbon automapping rules on namespaces changes (#2793)
  Enforce matching retention and index block size (#2783)
  [query] Add ClusterNamespacesWatcher and use to generate downsample automapper rules (#2782)
  [query][dbnode] Wire up etcd-backed Clusters implementation in coordinator (#2758)
  [query] Fix quantile() argument not being passed through (#2780)
  [query] Add "median" aggregation to Graphite aggregate() function (#2774)
  [r2] Ensure KeepOriginal is propagated when adding/reviving rules (#2796)
  [dbnode] Update default db read limits  (#2784)
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.

5 participants