hanahmily opened a new pull request, #1170:
URL: https://github.com/apache/skywalking-banyandb/pull/1170
## What
Commit `06d592e` added a TTL deadline filter in `SelectSegments` to stop
queries from returning data from fully-expired segments that the retention
cron hasn't physically removed yet. However, the filter was gated on
`reopenClosed=true`, which is the flag used exclusively by data-query
callers. All metadata and stats listing call sites pass `reopenClosed=false`
to avoid reopening cold bluge-index writers, so they silently bypassed the
filter and continued returning expired segments to OAP/bydbctl.
## Fix
Drop `!reopenClosed` from the bypass condition in `database.SelectSegments`
(`tsdb.go:282`):
```go
// before
if err != nil || !reopenClosed || d.disableRetention {
// after
if err != nil || d.disableRetention {
```
The TTL filter now applies regardless of whether the caller intends to
reopen closed segments.
## Safety
`DecRef` accounting is correct on the `reopenClosed=false` path:
- **CAS-bumped segment** (`refCount > 0` at scan): bumped by exactly +1
inside `selectSegments`; the filter's `s.DecRef()` balances it.
- **Unbumped dormant segment** (`refCount <= 0`): `DecRef` opens with
`if current <= 0 { return }` — an explicit no-op, cannot go negative.
All six `reopenClosed=false` metadata call sites already loop-`DecRef`
every returned segment, so no caller-side changes are needed.
## Test
Added
`TestSelectSegmentsRetention/metadata_path_excludes_fully_expired_segments`
to `tsdb_test.go`, calling `SelectSegments(wide, false)` and asserting that
only the non-expired segment is returned. The two existing subtests
(`reopenClosed=true`) are unaffected.
## Related
Fixes the gap left by #1149 for the metadata/stats listing paths.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]