-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Resort store response set on internal label dedup #6317
Merged
fpetkovski
merged 14 commits into
thanos-io:main
from
fpetkovski:resort-dataset-on-internal-dedup
Aug 10, 2023
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a84375f
Resort store response set on internal label dedup
fpetkovski 00ce595
Resort data in TSDB
fpetkovski 9d4628b
Fix bucket_test.go
fpetkovski 0ea795e
Fix TSDB store
fpetkovski dd9b052
Remove print statements
fpetkovski 6d37f8a
Flush at end of Series call
fpetkovski c779697
Fix bucket test
fpetkovski f230301
Cleanup code
fpetkovski 26cbd33
Clean up e2e/query_test.go
fpetkovski 2f659ad
Fix bucket test
fpetkovski db076c8
Use index header to read labels
fpetkovski e185d04
Remove redundant comments
fpetkovski 87bcbce
Merge branch 'main' into resort-dataset-on-internal-dedup
fpetkovski 8c511ac
Fix lint
fpetkovski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,40 +97,31 @@ func NewMultiTSDB( | |
|
||
type localClient struct { | ||
storepb.StoreClient | ||
labelSetFunc func() []labelpb.ZLabelSet | ||
timeRangeFunc func() (int64, int64) | ||
tsdbOpts *tsdb.Options | ||
store *store.TSDBStore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice cleanup <3 |
||
} | ||
|
||
func NewLocalClient( | ||
c storepb.StoreClient, | ||
labelSetFunc func() []labelpb.ZLabelSet, | ||
timeRangeFunc func() (int64, int64), | ||
tsdbOpts *tsdb.Options, | ||
) store.Client { | ||
func newLocalClient(c storepb.StoreClient, store *store.TSDBStore) *localClient { | ||
return &localClient{ | ||
StoreClient: c, | ||
labelSetFunc: labelSetFunc, | ||
timeRangeFunc: timeRangeFunc, | ||
tsdbOpts: tsdbOpts, | ||
StoreClient: c, | ||
store: store, | ||
} | ||
} | ||
|
||
func (l *localClient) LabelSets() []labels.Labels { | ||
return labelpb.ZLabelSetsToPromLabelSets(l.labelSetFunc()...) | ||
return labelpb.ZLabelSetsToPromLabelSets(l.store.LabelSet()...) | ||
} | ||
|
||
func (l *localClient) TimeRange() (mint int64, maxt int64) { | ||
return l.timeRangeFunc() | ||
return l.store.TimeRange() | ||
} | ||
|
||
func (l *localClient) TSDBInfos() []infopb.TSDBInfo { | ||
labelsets := l.labelSetFunc() | ||
labelsets := l.store.LabelSet() | ||
if len(labelsets) == 0 { | ||
return []infopb.TSDBInfo{} | ||
} | ||
|
||
mint, maxt := l.timeRangeFunc() | ||
mint, maxt := l.store.TimeRange() | ||
return []infopb.TSDBInfo{ | ||
{ | ||
Labels: labelsets[0], | ||
|
@@ -141,7 +132,7 @@ func (l *localClient) TSDBInfos() []infopb.TSDBInfo { | |
} | ||
|
||
func (l *localClient) String() string { | ||
mint, maxt := l.timeRangeFunc() | ||
mint, maxt := l.store.TimeRange() | ||
return fmt.Sprintf( | ||
"LabelSets: %v MinTime: %d MaxTime: %d", | ||
labelpb.PromLabelSetsToString(l.LabelSets()), mint, maxt, | ||
|
@@ -186,7 +177,7 @@ func (t *tenant) store() *store.TSDBStore { | |
return t.storeTSDB | ||
} | ||
|
||
func (t *tenant) client(logger log.Logger, tsdbOpts *tsdb.Options) store.Client { | ||
func (t *tenant) client(logger log.Logger) store.Client { | ||
t.mtx.RLock() | ||
defer t.mtx.RUnlock() | ||
|
||
|
@@ -196,7 +187,7 @@ func (t *tenant) client(logger log.Logger, tsdbOpts *tsdb.Options) store.Client | |
} | ||
|
||
client := storepb.ServerAsClient(store.NewRecoverableStoreServer(logger, tsdbStore), 0) | ||
return NewLocalClient(client, tsdbStore.LabelSet, tsdbStore.TimeRange, tsdbOpts) | ||
return newLocalClient(client, tsdbStore) | ||
} | ||
|
||
func (t *tenant) exemplars() *exemplars.TSDB { | ||
|
@@ -495,7 +486,7 @@ func (t *MultiTSDB) TSDBLocalClients() []store.Client { | |
|
||
res := make([]store.Client, 0, len(t.tenants)) | ||
for _, tenant := range t.tenants { | ||
client := tenant.client(t.logger, t.tsdbOpts) | ||
client := tenant.client(t.logger) | ||
if client != nil { | ||
res = append(res, client) | ||
} | ||
|
@@ -876,6 +867,19 @@ func (t *MultiTSDB) extractTenantsLabels(tenantID string, initialLset labels.Lab | |
return initialLset, nil | ||
} | ||
|
||
func (t *MultiTSDB) UpdateLabelNames(ctx context.Context) { | ||
t.mtx.RLock() | ||
defer t.mtx.RUnlock() | ||
|
||
for _, tenant := range t.tenants { | ||
db := tenant.storeTSDB | ||
if db == nil { | ||
continue | ||
} | ||
db.UpdateLabelNames(ctx) | ||
} | ||
} | ||
|
||
// extendLabels extends external labels of the initial label set. | ||
// If an external label shares same name with a label in the initial label set, | ||
// use the label in the initial label set and inform user about it. | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 guess info would make sense here