Sort lineage entries by timestamp then id for deterministic list output#18859
Draft
spapin wants to merge 1 commit into
Draft
Sort lineage entries by timestamp then id for deterministic list output#18859spapin wants to merge 1 commit into
spapin wants to merge 1 commit into
Conversation
Contributor
Author
|
The biggest benefit for this PR is to fix the flaky test on fast machines. This isn't an impactful bug otherwise. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #18859 +/- ##
============================================
+ Coverage 57.00% 64.82% +7.81%
- Complexity 7 1322 +1315
============================================
Files 2607 3393 +786
Lines 152679 211308 +58629
Branches 24816 33226 +8410
============================================
+ Hits 87041 136971 +49930
- Misses 58227 63277 +5050
- Partials 7411 11060 +3649
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
51b27a4 to
4b7ef85
Compare
SegmentLineage.toJsonObject() sorted entries by millisecond timestamp only, over a HashMap, so entries sharing a millisecond came out in arbitrary (UUID-hash) order -- non-deterministic list output, and a ~29% flake in testListSegmentLineage (two back-to-back replaces share a millisecond ~57% of the time on a fast machine). Add the entry id as a sort tiebreaker so the output is deterministic for a given set of entries: (timestamp, then id). No change to id generation -- entries remain identified by UUID. testListSegmentLineage derives the expected order with the same (timestamp, id) sort and asserts the response matches.
4b7ef85 to
0dd64ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SegmentLineage.toJsonObject()sorted entries by millisecond timestamp only, over aHashMap. Entries sharing a millisecond fell back to arbitrary UUID-hash iteration order, so the list API output was non-deterministic.testListSegmentLineageasserts two back-to-backstartReplaceSegmentsentries appear in a fixed order; on a fast machine the two share a millisecond ~57% of the time, and the assertion failed ~29% of runs (measured over 1000 runs).Fix
Add the entry id as a sort tiebreaker: entries are ordered by
(timestamp, then id). This makes the list output deterministic for a given set of entries. Entries remain identified by UUID. The code generally doesn't make any use of the ordering, but segmentLineage prints a summary where segments at the same millisecond may appear out of order.The test derives the expected order with the same
(timestamp, id)sort and asserts the response lists the two entries in that order — deterministic regardless of whether the timestamps tie.