-
Notifications
You must be signed in to change notification settings - Fork 710
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
Cancel activedefrag in case we empty db #1411
Cancel activedefrag in case we empty db #1411
Conversation
Signed-off-by: Ran Shidlansik <[email protected]>
Signed-off-by: Ran Shidlansik <[email protected]>
@JimB123 can you please take a look? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1411 +/- ##
============================================
+ Coverage 70.78% 70.85% +0.06%
============================================
Files 118 118
Lines 63561 63596 +35
============================================
+ Hits 44994 45059 +65
+ Misses 18567 18537 -30
|
Before doing this, I'd like to look at the defrag code to see if there's a better solution. But this is certainly an option. |
Would a better solution be to modify The only thing that needs to be check is if I'm worried about a RL case I saw once... A customer had 2 DBs, a big one and a small one. They were repeatedly flushing the small one (every few seconds). If we cancel the entire defrag operation, the bigger/stable DB might keep getting interrupted before completing defrag - and repeatedly have to start over from the beginning. |
Yes this is something we discussed and I agree is a potential issue. I think working with indexes should always be preferred.
I do not think there is any issue with that the cursor is blind to memory location AFAIK. |
Not exactly, I think that reduces the flexibility of the kvstore helper - which is used for other kvstores (like pubsub). What I'm thinking is to:
|
Arbitrary point. No crash. But what if the SWAPDB command is used? Worst case, defrag will miss some keys? I can't imagine a use case for repeatedly calling SWAPDB. |
We could also maintain the mapping between a logical database ID and actual database ID. At startup, database with logical id 1 will always have that logical id, but it's actual database ID might change with swaps. For cases we want to traverse the DBs in the original intended order, than we can use the logic that Jim outlined but run the database ID through the mapping. For example, if we 4 original database IDs, 1->1, 2->2, 3->3, 4->4. If we swap 2 and 3, the mapping becomes 1->1, 2->3, 3->2, 4->4. So when we traverse through the mapping, we are able to hit the databases in their original order. The hot path will still directly look up the real database, and this logical mapping will be used for less frequently accessed cron jobs. |
I believe this can be closed. I addressed this in #1430 Now, if the kvstore is deleted or swapped, defrag will just continue onto the next defrag stage. If there is still fragmentation after the cycle is complete (a fragmented DB swapped) then it will get picked up in the next cycle. |
@ranshid Can you close this if you agree with Jim? |
Closed as this is handled as part of #1430 |
In case we empty database (eg user triggers flushdb command) the activedefrag might be in the process of scanning over the db kvstore.
Example:
In order to avoid such issues we will reset activedefrag to start all over again.