Skip to content

Commit

Permalink
Use a different info field to indicate sorted series
Browse files Browse the repository at this point in the history
Signed-off-by: Filip Petkovski <[email protected]>
  • Loading branch information
fpetkovski committed Oct 22, 2022
1 parent 2a1c166 commit 3d579b5
Show file tree
Hide file tree
Showing 16 changed files with 174 additions and 98 deletions.
10 changes: 6 additions & 4 deletions cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

v1 "github.com/prometheus/prometheus/web/api/v1"
"github.com/thanos-community/promql-engine/engine"

apiv1 "github.com/thanos-io/thanos/pkg/api/query"
"github.com/thanos-io/thanos/pkg/compact/downsample"
"github.com/thanos-io/thanos/pkg/component"
Expand Down Expand Up @@ -734,10 +735,11 @@ func runQuery(
if httpProbe.IsReady() {
mint, maxt := proxy.TimeRange()
return &infopb.StoreInfo{
MinTime: mint,
MaxTime: maxt,
SupportsSharding: true,
SendsSortedSeries: true,
MinTime: mint,
MaxTime: maxt,
SupportsSharding: true,
SendsSortedSeries: true,
SendsSortedSeriesWithoutLabels: true,
}
}
return nil
Expand Down
9 changes: 5 additions & 4 deletions cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,11 @@ func runReceive(
if httpProbe.IsReady() {
minTime, maxTime := mts.TimeRange()
return &infopb.StoreInfo{
MinTime: minTime,
MaxTime: maxTime,
SupportsSharding: true,
SendsSortedSeries: true,
MinTime: minTime,
MaxTime: maxTime,
SupportsSharding: true,
SendsSortedSeries: true,
SendsSortedSeriesWithoutLabels: true,
}
}
return nil
Expand Down
9 changes: 5 additions & 4 deletions cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,11 @@ func runRule(
if httpProbe.IsReady() {
mint, maxt := tsdbStore.TimeRange()
return &infopb.StoreInfo{
MinTime: mint,
MaxTime: maxt,
SupportsSharding: true,
SendsSortedSeries: true,
MinTime: mint,
MaxTime: maxt,
SupportsSharding: true,
SendsSortedSeries: true,
SendsSortedSeriesWithoutLabels: true,
}
}
return nil
Expand Down
9 changes: 5 additions & 4 deletions cmd/thanos/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,11 @@ func runSidecar(
if httpProbe.IsReady() {
mint, maxt := promStore.Timestamps()
return &infopb.StoreInfo{
MinTime: mint,
MaxTime: maxt,
SupportsSharding: true,
SendsSortedSeries: true,
MinTime: mint,
MaxTime: maxt,
SupportsSharding: true,
SendsSortedSeries: true,
SendsSortedSeriesWithoutLabels: true,
}
}
return nil
Expand Down
9 changes: 5 additions & 4 deletions cmd/thanos/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,11 @@ func runStore(
if httpProbe.IsReady() {
mint, maxt := bs.TimeRange()
return &infopb.StoreInfo{
MinTime: mint,
MaxTime: maxt,
SupportsSharding: true,
SendsSortedSeries: true,
MinTime: mint,
MaxTime: maxt,
SupportsSharding: true,
SendsSortedSeries: true,
SendsSortedSeriesWithoutLabels: true,
}
}
return nil
Expand Down
1 change: 0 additions & 1 deletion internal/cortex/querier/queryrange/queryrange.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 76 additions & 38 deletions pkg/info/infopb/rpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 26 additions & 22 deletions pkg/info/infopb/rpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,45 @@ option (gogoproto.goproto_sizecache_all) = false;

// Info represents the API that is responsible for gathering metadata about the all APIs supported by the component.
service Info {
// Info returns the metadata (Eg. LabelSets, Min/Max time) about all the APIs the component supports.
rpc Info(InfoRequest) returns (InfoResponse);
// Info returns the metadata (Eg. LabelSets, Min/Max time) about all the APIs the component supports.
rpc Info(InfoRequest) returns (InfoResponse);
}

message InfoRequest {}

message InfoResponse {
repeated ZLabelSet label_sets = 1 [(gogoproto.nullable) = false];
string ComponentType = 2;
repeated ZLabelSet label_sets = 1 [(gogoproto.nullable) = false];
string ComponentType = 2;

// StoreInfo holds the metadata related to Store API if exposed by the component otherwise it will be null.
StoreInfo store = 3;
// StoreInfo holds the metadata related to Store API if exposed by the component otherwise it will be null.
StoreInfo store = 3;

// RulesInfo holds the metadata related to Rules API if exposed by the component otherwise it will be null.
RulesInfo rules = 4;
// RulesInfo holds the metadata related to Rules API if exposed by the component otherwise it will be null.
RulesInfo rules = 4;

// MetricMetadataInfo holds the metadata related to Metadata API if exposed by the component otherwise it will be null.
MetricMetadataInfo metric_metadata = 5;
// MetricMetadataInfo holds the metadata related to Metadata API if exposed by the component otherwise it will be null.
MetricMetadataInfo metric_metadata = 5;

// TargetsInfo holds the metadata related to Targets API if exposed by the component otherwise it will be null.
TargetsInfo targets = 6;
// TargetsInfo holds the metadata related to Targets API if exposed by the component otherwise it will be null.
TargetsInfo targets = 6;

// ExemplarsInfo holds the metadata related to Exemplars API if exposed by the component otherwise it will be null.
ExemplarsInfo exemplars = 7;
// ExemplarsInfo holds the metadata related to Exemplars API if exposed by the component otherwise it will be null.
ExemplarsInfo exemplars = 7;

// QueryAPIInfo holds the metadata related to Query API if exposed by the component, otherwise it will be null.
QueryAPIInfo query = 8;
// QueryAPIInfo holds the metadata related to Query API if exposed by the component, otherwise it will be null.
QueryAPIInfo query = 8;
}

// StoreInfo holds the metadata related to Store API exposed by the component.
message StoreInfo {
int64 min_time = 1;
int64 max_time = 2;
bool supports_sharding = 3;
bool sends_sorted_series = 4;
int64 min_time = 1;
int64 max_time = 2;
bool supports_sharding = 3;

// TODO(fpetkovski): Remove in v1.0
bool sends_sorted_series = 4;
// TODO(fpetkovski): Remove in v1.0
bool sends_sorted_series_without_labels = 5;
}

// RulesInfo holds the metadata related to Rules API exposed by the component.
Expand All @@ -73,8 +77,8 @@ message TargetsInfo {

// ExemplarsInfo holds the metadata related to Exemplars API exposed by the component.
message ExemplarsInfo {
int64 min_time = 1;
int64 max_time = 2;
int64 min_time = 1;
int64 max_time = 2;
}

// QueryInfo holds the metadata related to Query API exposed by the component.
Expand Down
11 changes: 11 additions & 0 deletions pkg/query/endpointset.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,17 @@ func (er *endpointRef) SendsSortedSeries() bool {
return er.metadata.Store.SendsSortedSeries
}

func (er *endpointRef) SendsSeriesSortedForDedup() bool {
er.mtx.RLock()
defer er.mtx.RUnlock()

if er.metadata == nil || er.metadata.Store == nil {
return false
}

return er.metadata.Store.SendsSortedSeriesWithoutLabels
}

func (er *endpointRef) String() string {
mint, maxt := er.TimeRange()
return fmt.Sprintf(
Expand Down
4 changes: 4 additions & 0 deletions pkg/query/internal/test-storeset-pre-v0.8.0/storeset.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ func (s *storeRef) SendsSortedSeries() bool {
return false
}

func (s *storeRef) SendsSeriesSortedForDedup() bool {
return false
}

func (s *storeRef) String() string {
mint, maxt := s.TimeRange()
return fmt.Sprintf(
Expand Down
7 changes: 4 additions & 3 deletions pkg/query/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ func (i inProcessClient) SupportsSharding() bool {
return false
}

func (i inProcessClient) SendsSortedSeries() bool { return false }
func (i inProcessClient) String() string { return i.name }
func (i inProcessClient) Addr() (string, bool) { return i.name, true }
func (i inProcessClient) SendsSortedSeries() bool { return false }
func (i inProcessClient) String() string { return i.name }
func (i inProcessClient) Addr() (string, bool) { return i.name, true }
func (i inProcessClient) SendsSeriesSortedForDedup() bool { return false }
4 changes: 4 additions & 0 deletions pkg/receive/multitsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ func (l *localClient) SupportsSharding() bool {
}

func (l *localClient) SendsSortedSeries() bool {
return true
}

func (l *localClient) SendsSeriesSortedForDedup() bool {
return l.sendsSortedSeries
}

Expand Down
Loading

0 comments on commit 3d579b5

Please sign in to comment.