-
Notifications
You must be signed in to change notification settings - Fork 36
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: condition for deleting old timestamp offsets #1186
Merged
+174
−5
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
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.
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.
Hm, I think there could be something else wrong here.
With few pids, less than keepNumberOfEntries, we would never delete from db.
Also, when > keepNumberOfEntries we evict, and thereby state.oldestTimestamp is updated to the oldest we have in memory, but there could still be older in db. Meaning that if we evict all the time we might never delete. Now we also have the evictThresholdReached so we don't evict all the time and thereby it might anyway delete.
However, feels like we should have two separate oldestTimestamp, one for what is in memory, and another for what is in the db.
Then this delete condition should maybe not involve currentState.size, but only look at the db time window. Alternatively, have a separate counter for inserted records and let that drive when a delete should be performed.
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.
Yes, that's what was being seen, and the only thing this PR is fixing. It now triggers deletion based on either the number of entries or the window (where this is a negative condition so needs to be
and/&&
).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.
Was going to mention possible issues around eviction overlapping with this. The eviction is:
So it only evicts when there's both the oldest timestamp is too old and the number of entries have gone over the limit. In the example case that prompted this PR, the number of entries is always below the limit, so there won't be any eviction. Allowing the deletion trigger to just be based on the time window.
For the case where there are more persistence ids, it could certainly trigger eviction in a way that prevents deletion — but may trigger on subsequent timer. The latest by slice are always kept, so would trigger if the time range across slices is bigger than the time window. Or if new persistence ids are being seen, so that it evicts (reducing to the limit), then new persistence ids (but no older timestamps, so doesn't evict yet), then deletion timer and triggers deletion based on size.
Agree that the overlaps between eviction and deletion need to be addressed in some way. Could be clearer with some separate mechanism.
Or a simple fix for this could be to have eviction trigger deletion. So if it has evicted entries, set a flag for the next deletion timer to always trigger. Similar to the idle flag that's already there to prevent unnecessary deletion. And then remove the condition based on size, which will already be there based on eviction.
I'll look at creating some test scenarios for the different cases.
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 tests for these scenarios, in 5e4b32c
Then updated from having the condition on keep-number-of-entries to always triggering next deletion after an eviction (which has checked for both over limit and outside time window). Still triggers deletion on time window, for when fewer pids than limit (no eviction). Last test scenarios updated for the new trigger. See
9e0e35a3673969.