-
Notifications
You must be signed in to change notification settings - Fork 880
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: Run defrag on dbs > 0 as well #1737
Conversation
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
15fae99
to
9cdef8c
Compare
src/server/engine_shard_set.cc
Outdated
// Once we're done with a db, jump to the next | ||
if (defrag_state_.cursor == kCursorDoneState) { | ||
defrag_state_.dbid++; | ||
// Skip null dbs that still take up slots in the array | ||
while (defrag_state_.dbid < slice.db_array_size() && !slice.IsDbValid(defrag_state_.dbid)) | ||
defrag_state_.dbid++; | ||
} |
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, if the db has less elements than kMaxTraverses, then it will proceed with the next db only on the next phase. I don't see it as a big flaw given that kMaxTraverses
is only 40 now.
@@ -137,8 +141,8 @@ bool EngineShard::DoDefrag() { | |||
const float threshold = GetFlag(FLAGS_mem_defrag_page_utilization_threshold); | |||
|
|||
auto& slice = db_slice(); | |||
DCHECK(slice.IsDbValid(kDefaultDbIndex)); | |||
auto [prime_table, expire_table] = slice.GetTables(kDefaultDbIndex); | |||
DCHECK(slice.IsDbValid(defrag_state_.dbid)); |
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.
do we ever reduce number of our databases? i.e. flushall?
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.
We don't, see DbSlice::FlushDb
But I can change it a little nonetheless to make it safer
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
* fix: Run defrag on dbs > 0 as well Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
No description provided.