Skip to content

fix: Fix wrong split pruning on timestamp#70

Merged
Darkheir merged 1 commit into
sekoiafrom
fix/timestamp_wrong_pruning
Jun 25, 2026
Merged

fix: Fix wrong split pruning on timestamp#70
Darkheir merged 1 commit into
sekoiafrom
fix/timestamp_wrong_pruning

Conversation

@Darkheir

Copy link
Copy Markdown
Collaborator

Description

Some splits may be pruned containing documents that should be included in the response

How was this PR tested?

Describe how you tested this PR.

Signed-off-by: Darkheir <raphael.cohen@sekoia.io>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect split pruning when sorting by timestamp descending by aligning worst-hit timestamp bucketing with how split timestamp bounds are stored, preventing splits from being pruned when they may contain better (newer) documents within the same second.

Changes:

  • Update CanSplitDoBetter::record_new_worst_hit for SplitTimestampHigher / FindTraceIdsAggregation to use second truncation consistent with split metadata (avoids false pruning around sub-second boundaries).
  • Add a regression test covering a sub-second worst-hit scenario to ensure a split in the same second is not incorrectly pruned.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1198 to +1202
// Split timestamp_end is stored as floor(doc_nanos / 1e9). To avoid
// pruning a split that straddles the worst-hit boundary (e.g. worst
// hit at 1.5 s, split timestamp_end = 1 s, but split contains a doc
// at 1.7 s), we must use floor here as well, not div_ceil.
*timestamp = Some(timestamp_ns / 1_000_000_000);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we can have negative timestamps

@rdettai-sk rdettai-sk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well spotted

@Darkheir Darkheir merged commit b7d9d0c into sekoia Jun 25, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants