Skip to content

Commit

Permalink
add additional sorting to stabilize remove stale segments
Browse files Browse the repository at this point in the history
  • Loading branch information
bitsofbits committed Jul 14, 2022
1 parent d90b3d3 commit 85231e7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gpsdio_segment/segmenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ def _remove_excess_segments(self):
while len(self._segments) >= self.max_open_segments:
# Remove oldest segment
segs = list(self._segments.items())
segs.sort(key=lambda x: x[1].last_msg["timestamp"])
segs.sort(
key=lambda x: (x[1].last_msg["timestamp"], x[1].last_msg["msgid"])
)
stalest_seg_id, _ = segs[0]
log("Removing stale segment {}".format(stalest_seg_id))
yield from self._clean_segment(
Expand Down

0 comments on commit 85231e7

Please sign in to comment.