-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ring buffer gap cleanup code #578
Fix ring buffer gap cleanup code #578
Conversation
@@ -328,17 +328,24 @@ def _cleanup_gaps(self) -> None: | |||
self._gaps = sorted(self._gaps, key=lambda x: x.start.timestamp()) | |||
|
|||
i = 0 | |||
while i < len(self._gaps) - 1: | |||
while i < len(self._gaps): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Def should have a test for this and the other new case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a case for the new case at least
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added another test case for the "old" bug.
Your commit message claims
But I don't think it's true. It's covered right here: # Delete out-of-date gaps
if w_1.end <= self._datetime_oldest:
del self._gaps[i] |
About having gaps whos start time is older than the oldest.. I am not sure that's really important, but I guess it doesn't hurt to clamp it |
0bfebed
to
270ea9c
Compare
Also, in your commit message you're wrongly using "then" when it should be "than" :) |
No, that case deletes the whole gap once it's fully outside of the buffer, i.e. it looks only at the end of the gap. The new case looks at and updates the beginning of the gap. |
270ea9c
to
f08ead6
Compare
We need that in the moving window. But maybe it's not a bug, but more like we covering an unforeseen use case. We want to know the number of missing items in the window and now we can simply sum up the length of all gaps. |
I am sorry, but I am confused. The commit message talks literally about the end date being older than oldest timestamp
And this matches also what you say my case is..
This though
is true, however the message should then say "Clean up gap starts if they are before the oldest timestamp" or so |
PR LGTM, just the first commit message greatly confuses |
Did I ever mention that I'm having troubles with signs :D. Indeed the the start time of the gap is meant. I'll update the message accordingly. |
When cleaning up gaps the case that a gaps start date can become older than the oldest stored value in the buffer wasn't covered. Furthermore the cases for cleaning up a single gap didn't run for the last gaps, since the loop was stopping too early. Signed-off-by: Matthias Wende <matthias.wende@frequenz.com>
Adds a test case for updating the start time of gaps when it's older than the oldest stored element in the buffer. Signed-off-by: Matthias Wende <matthias.wende@frequenz.com>
Signed-off-by: Matthias Wende <matthias.wende@frequenz.com>
Signed-off-by: Matthias Wende <matthias.wende@frequenz.com>
f08ead6
to
d8eaaeb
Compare
|
||
## Bug Fixes | ||
|
||
- Fixes a bug in the ring buffer updating the end timestamp of gaps when they are outdated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are a bad bad boy. You should have first approved and merged #574.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wops
When cleaning up gaps the case that a gaps start date can become older then the oldest stored value in the buffer wasn't covered. Furthermore the cases for cleaning up a single gap didn't run for the last gaps, since the loop was stopping to early.