Skip to content

Commit

Permalink
lib/logstorage: always check the previous indexBlockHeader for blocks…
Browse files Browse the repository at this point in the history
… with matching tenantID and/or streamID

The previous indexBlockHeader may contain blocks for the matching tenantID and/or streamID,
so it must be scanned unconditionally during the search.

Updates #5295
Updates #4856

This is a follow-up for 89dcbc2
  • Loading branch information
valyala committed Nov 14, 2023
1 parent 77033db commit 9760221
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/VictoriaLogs/CHANGELOG.md
Expand Up @@ -18,6 +18,7 @@ according to [these docs](https://docs.victoriametrics.com/VictoriaLogs/QuickSta

## tip

* BUGFIX: properly locate logs for the [requested streams](https://docs.victoriametrics.com/VictoriaLogs/LogsQL.html#stream-filter). Previously logs for some streams may be missing in query results. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4856). Thanks to @XLONG96 for [the fix](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/5295)!
* BUGFIX: [web UI](https://docs.victoriametrics.com/VictoriaLogs/querying/#web-ui): properly sort found logs by time. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5300).


Expand Down
12 changes: 4 additions & 8 deletions lib/logstorage/storage_search.go
Expand Up @@ -382,10 +382,8 @@ func (p *part) searchByTenantIDs(so *searchOptions, bhss *blockHeaders, workCh c
n = sort.Search(len(ibhs), func(i int) bool {
return !ibhs[i].streamID.tenantID.less(tenantID)
})
if n == len(ibhs) || n > 0 && !ibhs[n].streamID.tenantID.equal(tenantID) {
// The end of ibhs[n-1] may contain blocks for the given tenantID, so move it backwards
n--
}
// The end of ibhs[n-1] may contain blocks for the given tenantID, so move it backwards
n--
}
ibh := &ibhs[n]
ibhs = ibhs[n+1:]
Expand Down Expand Up @@ -493,10 +491,8 @@ func (p *part) searchByStreamIDs(so *searchOptions, bhss *blockHeaders, workCh c
n = sort.Search(len(ibhs), func(i int) bool {
return !ibhs[i].streamID.less(streamID)
})
if n == len(ibhs) || n > 0 && !ibhs[n].streamID.equal(streamID) {
// The end of ibhs[n-1] may contain blocks for the given streamID, so move it backwards
n--
}
// The end of ibhs[n-1] may contain blocks for the given streamID, so move it backwards.
n--
}
ibh := &ibhs[n]
ibhs = ibhs[n+1:]
Expand Down

0 comments on commit 9760221

Please sign in to comment.