hanahmily opened a new pull request, #1149: URL: https://github.com/apache/skywalking-banyandb/pull/1149
## Problem Retention removes a segment only once its **whole** time range passes the deadline (`now - TTL`) — see `banyand/internal/storage/rotation.go` / `segmentController.remove`. A *partially* expired segment (`Start < deadline < End`) is therefore kept on disk, and the measure/stream/trace query paths had no lower-bound guard. So a query whose time range reached below `now - TTL` returned data points that were already expired. Example (daily segments, TTL = 3d): the day-`D` segment `[D, D+1)` is removed only at `now ≥ D+4d`; during `[D+3d, D+4d)` a point written at `D` is expired by the TTL but still queryable. ## Fix - Add `storage.TSDB.GetRetentionDeadline()` returning `now - TTL` (zero time when retention is disabled, making the clamp a no-op). - Clamp the query time range's lower bound to the deadline in the `measure`, `stream`, and `trace` `Query` paths, before segment selection. The measure clamp covers both the row path and the index-mode path. When the whole requested window is older than the deadline the query short-circuits to an empty result. ## Tests - Unit tests for the clamp helper (`measure`/`stream`/`trace`) and the `GetRetentionDeadline` primitive. - Integration cases `"excludes data expired beyond TTL"` in measure, stream, and trace, backed by data seeded beyond each group's TTL in `test/cases/init.go`. Each case was confirmed to **fail without the clamp** (negative control) and pass with it. ## Verification - `make build`, `make lint`, `make check`, `make license-check` pass. - Unit suites for `storage` / `measure` / `stream` / `trace` pass. - `standalone/query` integration suite passes (including the round2-after-restart and vectorized table variants); spot-checked `multi_segments`, `cold_query`, and `distributed/query`. -- 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]
