lib/storage: do not check for the result returned by db.doExtDB() where this isn't necessary

This simplifies the code a bit
This commit is contained in:
Aliaksandr Valialkin 2022-12-19 13:20:58 -08:00
parent 6530344a8f
commit 944effca54
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -741,7 +741,7 @@ func (db *indexDB) SearchLabelNamesWithFiltersOnTimeRange(qt *querytracer.Tracer
return nil, err
}
ok := db.doExtDB(func(extDB *indexDB) {
db.doExtDB(func(extDB *indexDB) {
qtChild := qt.NewChild("search for label names in the previous indexdb")
lnsLen := len(lns)
is := extDB.getIndexSearch(deadline)
@ -749,7 +749,7 @@ func (db *indexDB) SearchLabelNamesWithFiltersOnTimeRange(qt *querytracer.Tracer
extDB.putIndexSearch(is)
qtChild.Donef("found %d additional label names", len(lns)-lnsLen)
})
if ok && err != nil {
if err != nil {
return nil, err
}
@ -930,7 +930,7 @@ func (db *indexDB) SearchLabelValuesWithFiltersOnTimeRange(qt *querytracer.Trace
if err != nil {
return nil, err
}
ok := db.doExtDB(func(extDB *indexDB) {
db.doExtDB(func(extDB *indexDB) {
qtChild := qt.NewChild("search for label values in the previous indexdb")
lvsLen := len(lvs)
is := extDB.getIndexSearch(deadline)
@ -938,7 +938,7 @@ func (db *indexDB) SearchLabelValuesWithFiltersOnTimeRange(qt *querytracer.Trace
extDB.putIndexSearch(is)
qtChild.Donef("found %d additional label values", len(lvs)-lvsLen)
})
if ok && err != nil {
if err != nil {
return nil, err
}
@ -1132,14 +1132,14 @@ func (db *indexDB) SearchTagValueSuffixes(qt *querytracer.Tracer, tr TimeRange,
return nil, err
}
if len(tvss) < maxTagValueSuffixes {
ok := db.doExtDB(func(extDB *indexDB) {
db.doExtDB(func(extDB *indexDB) {
is := extDB.getIndexSearch(deadline)
qtChild := qt.NewChild("search tag value suffixes in the previous indexdb")
err = is.searchTagValueSuffixesForTimeRange(tvss, tr, tagKey, tagValuePrefix, delimiter, maxTagValueSuffixes)
qtChild.Done()
extDB.putIndexSearch(is)
})
if ok && err != nil {
if err != nil {
return nil, err
}
}
@ -1285,12 +1285,12 @@ func (db *indexDB) GetSeriesCount(deadline uint64) (uint64, error) {
}
var nExt uint64
ok := db.doExtDB(func(extDB *indexDB) {
db.doExtDB(func(extDB *indexDB) {
is := extDB.getIndexSearch(deadline)
nExt, err = is.getSeriesCount()
extDB.putIndexSearch(is)
})
if ok && err != nil {
if err != nil {
return 0, fmt.Errorf("error when searching in extDB: %w", err)
}
return n + nExt, nil
@ -1350,14 +1350,14 @@ func (db *indexDB) GetTSDBStatus(qt *querytracer.Tracer, tfss []*TagFilters, dat
if status.hasEntries() {
return status, nil
}
ok := db.doExtDB(func(extDB *indexDB) {
db.doExtDB(func(extDB *indexDB) {
qtChild := qt.NewChild("collect tsdb stats in the previous indexdb")
is := extDB.getIndexSearch(deadline)
status, err = is.getTSDBStatus(qtChild, tfss, date, focusLabel, topN, maxMetrics)
qtChild.Done()
extDB.putIndexSearch(is)
})
if ok && err != nil {
if err != nil {
return nil, fmt.Errorf("error when obtaining TSDB status from extDB: %w", err)
}
return status, nil
@ -1663,16 +1663,15 @@ func (db *indexDB) DeleteTSIDs(qt *querytracer.Tracer, tfss []*TagFilters) (int,
// Delete TSIDs in the extDB.
deletedCount := len(metricIDs)
if db.doExtDB(func(extDB *indexDB) {
db.doExtDB(func(extDB *indexDB) {
var n int
qtChild := qt.NewChild("deleting series from the previos indexdb")
n, err = extDB.DeleteTSIDs(qtChild, tfss)
qtChild.Donef("deleted %d series", n)
deletedCount += n
}) {
if err != nil {
return deletedCount, fmt.Errorf("cannot delete tsids in extDB: %w", err)
}
})
if err != nil {
return deletedCount, fmt.Errorf("cannot delete tsids in extDB: %w", err)
}
return deletedCount, nil
}
@ -1776,7 +1775,7 @@ func (db *indexDB) searchMetricIDs(qt *querytracer.Tracer, tfss []*TagFilters, t
qtChild.Done()
var extMetricIDs []uint64
if db.doExtDB(func(extDB *indexDB) {
db.doExtDB(func(extDB *indexDB) {
qtChild := qt.NewChild("search for metricIDs in the previous indexdb")
defer qtChild.Done()
@ -1794,10 +1793,9 @@ func (db *indexDB) searchMetricIDs(qt *querytracer.Tracer, tfss []*TagFilters, t
extMetricIDs, err = is.searchMetricIDs(qtChild, tfss, tr, maxMetrics)
extDB.putIndexSearch(is)
extDB.putMetricIDsToTagFiltersCache(qtChild, extMetricIDs, tfKeyExtBuf.B)
}) {
if err != nil {
return nil, fmt.Errorf("error when searching for metricIDs in the previous indexdb: %s", err)
}
})
if err != nil {
return nil, fmt.Errorf("error when searching for metricIDs in the previous indexdb: %s", err)
}
// Merge localMetricIDs with extMetricIDs.