Conversation
bd5812d to
5ca1fa6
Compare
Greptile OverviewGreptile SummaryThis PR introduces delete-on-empty (DOE) behavior to the
Key places this integrates with the rest of the codebase are Blocking issues to address before merge are centered around DOE safety/progress: stale DOE keys can cause deletion even when DOE is disabled in current config; DOE scanning pagination can repeatedly process the same first page without ever making forward progress under load; and the new generic jitter helper in bgtasks should handle edge-case intervals defensively. Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Backend
participant Streamer
participant DB as SlateDB
participant Bgtasks
Client->>Backend: create_or_reconfigure_stream(basin, stream, config)
Backend->>DB: txn.put(stream_meta)
Backend->>DB: txn.put(stream_id_mapping)
Backend->>DB: txn.put(stream_tail_position(StreamPosition::MIN, created_at_secs))
alt DOE enabled & changed
Backend->>DB: txn.put(stream_doe_deadline(after(min_age), stream_id), min_age)
end
Backend-->>Client: Ok
Client->>Backend: append(records)
Backend->>Streamer: handle append
Streamer->>Streamer: maybe_doe_deadline(retention_age, min_age)
Streamer->>DB: write batch
opt DOE deadline scheduled
Streamer->>DB: put(stream_doe_deadline(deadline, stream_id), min_age)
end
Streamer->>DB: put(stream_tail_position(next_pos, now_secs))
Bgtasks->>Backend: tick_stream_doe()
Backend->>DB: scan expired stream_doe_deadline keys
loop per stream_id (grouped)
Backend->>DB: scan stream_record_timestamp to check emptiness
Backend->>DB: get stream_tail_position to check eligibility
alt empty & eligible & mapping exists
Backend->>Backend: delete_stream(basin, stream)
Backend->>DB: mark stream_meta.deleted_at
end
Backend->>DB: delete stream_doe_deadline keys (clear deadlines)
end
|
dd9be0f to
295098a
Compare
|
@greptileai review this |
Additional Comments (2)
Prompt To Fix With AIThis is a comment left during a code review.
Path: lite/src/backend/bgtasks/mod.rs
Line: 132:140
Comment:
**Jitter math can panic**
`jittered_delay` computes `max_ms` as `interval/10` and then calls `rand::random_range(-max_ms..=max_ms)`. For small intervals (<10ms), `max_ms` becomes 0, so the range is `0..=0` (fine), but `random_range` expects a non-empty range; and if `interval` is 0, later `interval - Duration::from_millis(...)` can underflow/panic. Even if current call sites use 60s, this helper is generic and can be reused. Consider explicitly handling `interval.is_zero()` and `max_ms == 0` by returning `interval` without calling `random_range`.
How can I resolve this? If you propose a fix, please make it concise.
In Prompt To Fix With AIThis is a comment left during a code review.
Path: lite/src/backend/streams.rs
Line: 2016:2054
Comment:
**Tail position init mismatch**
In `create_or_reconfigure_stream`, newly-created streams now write an initial `stream_tail_position` value (with `StreamPosition::MIN` and `write_timestamp_secs = created_at`). But other code paths treat a missing tail position as “never written” (e.g., `stream_doe_is_eligible` returns `false` if tail position is missing). With this initialization, a stream that has never had records can become DOE-eligible based purely on `created_at`, which is a behavioral change. If that’s not intended, consider leaving tail position absent until first append, or storing a sentinel write timestamp distinct from creation time.
How can I resolve this? If you propose a fix, please make it concise. |
## 🤖 New release * `s2-lite`: 0.27.5 -> 0.28.0 (✓ API compatible changes) * `s2-cli`: 0.27.5 -> 0.28.0 <details><summary><i><b>Changelog</b></i></summary><p> ## `s2-lite` <blockquote> ## [0.28.0] - 2026-02-06 ### Features - [**breaking**] Delete-on-empty ([#158](#158)) ### Bug Fixes - Append session should also `create-stream-on-append` if configured ([#180](#180)) <!-- generated by git-cliff --> </blockquote> ## `s2-cli` <blockquote> ## [0.28.0] - 2026-02-06 ### Miscellaneous Tasks - Update Cargo.lock dependencies <!-- generated by git-cliff --> </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Closes #152