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 371f9085c9
commit 2184de3bf2
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1

View File

@ -764,7 +764,7 @@ func (db *indexDB) SearchLabelNamesWithFiltersOnTimeRange(qt *querytracer.Tracer
return nil, err 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") qtChild := qt.NewChild("search for label names in the previous indexdb")
lnsLen := len(lns) lnsLen := len(lns)
is := extDB.getIndexSearch(accountID, projectID, deadline) is := extDB.getIndexSearch(accountID, projectID, deadline)
@ -772,7 +772,7 @@ func (db *indexDB) SearchLabelNamesWithFiltersOnTimeRange(qt *querytracer.Tracer
extDB.putIndexSearch(is) extDB.putIndexSearch(is)
qtChild.Donef("found %d additional label names", len(lns)-lnsLen) qtChild.Donef("found %d additional label names", len(lns)-lnsLen)
}) })
if ok && err != nil { if err != nil {
return nil, err return nil, err
} }
@ -952,7 +952,7 @@ func (db *indexDB) SearchTenants(qt *querytracer.Tracer, tr TimeRange, deadline
if err != nil { if err != nil {
return nil, err return nil, err
} }
ok := db.doExtDB(func(extDB *indexDB) { db.doExtDB(func(extDB *indexDB) {
qtChild := qt.NewChild("search for tenants in the previous indexdb") qtChild := qt.NewChild("search for tenants in the previous indexdb")
tenantsLen := len(tenants) tenantsLen := len(tenants)
is := extDB.getIndexSearch(0, 0, deadline) is := extDB.getIndexSearch(0, 0, deadline)
@ -960,7 +960,7 @@ func (db *indexDB) SearchTenants(qt *querytracer.Tracer, tr TimeRange, deadline
extDB.putIndexSearch(is) extDB.putIndexSearch(is)
qtChild.Donef("found %d additional tenants", len(tenants)-tenantsLen) qtChild.Donef("found %d additional tenants", len(tenants)-tenantsLen)
}) })
if ok && err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1081,7 +1081,7 @@ func (db *indexDB) SearchLabelValuesWithFiltersOnTimeRange(qt *querytracer.Trace
if err != nil { if err != nil {
return nil, err 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") qtChild := qt.NewChild("search for label values in the previous indexdb")
lvsLen := len(lvs) lvsLen := len(lvs)
is := extDB.getIndexSearch(accountID, projectID, deadline) is := extDB.getIndexSearch(accountID, projectID, deadline)
@ -1089,7 +1089,7 @@ func (db *indexDB) SearchLabelValuesWithFiltersOnTimeRange(qt *querytracer.Trace
extDB.putIndexSearch(is) extDB.putIndexSearch(is)
qtChild.Donef("found %d additional label values", len(lvs)-lvsLen) qtChild.Donef("found %d additional label values", len(lvs)-lvsLen)
}) })
if ok && err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1284,14 +1284,14 @@ func (db *indexDB) SearchTagValueSuffixes(qt *querytracer.Tracer, accountID, pro
return nil, err return nil, err
} }
if len(tvss) < maxTagValueSuffixes { if len(tvss) < maxTagValueSuffixes {
ok := db.doExtDB(func(extDB *indexDB) { db.doExtDB(func(extDB *indexDB) {
is := extDB.getIndexSearch(accountID, projectID, deadline) is := extDB.getIndexSearch(accountID, projectID, deadline)
qtChild := qt.NewChild("search tag value suffixes in the previous indexdb") qtChild := qt.NewChild("search tag value suffixes in the previous indexdb")
err = is.searchTagValueSuffixesForTimeRange(tvss, tr, tagKey, tagValuePrefix, delimiter, maxTagValueSuffixes) err = is.searchTagValueSuffixesForTimeRange(tvss, tr, tagKey, tagValuePrefix, delimiter, maxTagValueSuffixes)
qtChild.Done() qtChild.Done()
extDB.putIndexSearch(is) extDB.putIndexSearch(is)
}) })
if ok && err != nil { if err != nil {
return nil, err return nil, err
} }
} }
@ -1437,12 +1437,12 @@ func (db *indexDB) GetSeriesCount(accountID, projectID uint32, deadline uint64)
} }
var nExt uint64 var nExt uint64
ok := db.doExtDB(func(extDB *indexDB) { db.doExtDB(func(extDB *indexDB) {
is := extDB.getIndexSearch(accountID, projectID, deadline) is := extDB.getIndexSearch(accountID, projectID, deadline)
nExt, err = is.getSeriesCount() nExt, err = is.getSeriesCount()
extDB.putIndexSearch(is) extDB.putIndexSearch(is)
}) })
if ok && err != nil { if err != nil {
return 0, fmt.Errorf("error when searching in extDB: %w", err) return 0, fmt.Errorf("error when searching in extDB: %w", err)
} }
return n + nExt, nil return n + nExt, nil
@ -1502,14 +1502,14 @@ func (db *indexDB) GetTSDBStatus(qt *querytracer.Tracer, accountID, projectID ui
if status.hasEntries() { if status.hasEntries() {
return status, nil return status, nil
} }
ok := db.doExtDB(func(extDB *indexDB) { db.doExtDB(func(extDB *indexDB) {
qtChild := qt.NewChild("collect tsdb stats in the previous indexdb") qtChild := qt.NewChild("collect tsdb stats in the previous indexdb")
is := extDB.getIndexSearch(accountID, projectID, deadline) is := extDB.getIndexSearch(accountID, projectID, deadline)
status, err = is.getTSDBStatus(qtChild, tfss, date, focusLabel, topN, maxMetrics) status, err = is.getTSDBStatus(qtChild, tfss, date, focusLabel, topN, maxMetrics)
qtChild.Done() qtChild.Done()
extDB.putIndexSearch(is) extDB.putIndexSearch(is)
}) })
if ok && err != nil { if err != nil {
return nil, fmt.Errorf("error when obtaining TSDB status from extDB: %w", err) return nil, fmt.Errorf("error when obtaining TSDB status from extDB: %w", err)
} }
return status, nil return status, nil
@ -1815,17 +1815,16 @@ func (db *indexDB) DeleteTSIDs(qt *querytracer.Tracer, tfss []*TagFilters) (int,
// Delete TSIDs in the extDB. // Delete TSIDs in the extDB.
deletedCount := len(metricIDs) deletedCount := len(metricIDs)
if db.doExtDB(func(extDB *indexDB) { db.doExtDB(func(extDB *indexDB) {
var n int var n int
qtChild := qt.NewChild("deleting series from the previos indexdb") qtChild := qt.NewChild("deleting series from the previos indexdb")
n, err = extDB.DeleteTSIDs(qtChild, tfss) n, err = extDB.DeleteTSIDs(qtChild, tfss)
qtChild.Donef("deleted %d series", n) qtChild.Donef("deleted %d series", n)
deletedCount += n deletedCount += n
}) { })
if err != nil { if err != nil {
return deletedCount, fmt.Errorf("cannot delete tsids in extDB: %w", err) return deletedCount, fmt.Errorf("cannot delete tsids in extDB: %w", err)
} }
}
return deletedCount, nil return deletedCount, nil
} }
@ -1930,7 +1929,7 @@ func (db *indexDB) searchMetricIDs(qt *querytracer.Tracer, tfss []*TagFilters, t
qtChild.Done() qtChild.Done()
var extMetricIDs []uint64 var extMetricIDs []uint64
if db.doExtDB(func(extDB *indexDB) { db.doExtDB(func(extDB *indexDB) {
qtChild := qt.NewChild("search for metricIDs in the previous indexdb") qtChild := qt.NewChild("search for metricIDs in the previous indexdb")
defer qtChild.Done() defer qtChild.Done()
@ -1948,11 +1947,10 @@ func (db *indexDB) searchMetricIDs(qt *querytracer.Tracer, tfss []*TagFilters, t
extMetricIDs, err = is.searchMetricIDs(qtChild, tfss, tr, maxMetrics) extMetricIDs, err = is.searchMetricIDs(qtChild, tfss, tr, maxMetrics)
extDB.putIndexSearch(is) extDB.putIndexSearch(is)
extDB.putMetricIDsToTagFiltersCache(qtChild, extMetricIDs, tfKeyExtBuf.B) extDB.putMetricIDsToTagFiltersCache(qtChild, extMetricIDs, tfKeyExtBuf.B)
}) { })
if err != nil { if err != nil {
return nil, fmt.Errorf("error when searching for metricIDs in the previous indexdb: %s", err) return nil, fmt.Errorf("error when searching for metricIDs in the previous indexdb: %s", err)
} }
}
// Merge localMetricIDs with extMetricIDs. // Merge localMetricIDs with extMetricIDs.
metricIDs = mergeSortedMetricIDs(localMetricIDs, extMetricIDs) metricIDs = mergeSortedMetricIDs(localMetricIDs, extMetricIDs)