-
Notifications
You must be signed in to change notification settings - Fork 83
Clean md store objects #8700
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
base: master
Are you sure you want to change the base?
Clean md store objects #8700
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,23 +58,39 @@ async function clean_md_store(last_date_to_remove) { | |
${total_objects_count} objects - Skipping...`); | ||
return; | ||
} | ||
const objects_to_remove = await clean_md_store_objects(last_date_to_remove, config.DB_CLEANER_DOCS_LIMIT); | ||
const blocks_to_remove = await clean_md_store_blocks(last_date_to_remove, config.DB_CLEANER_DOCS_LIMIT); | ||
const filtered_chunks = await clean_md_store_chunks(last_date_to_remove, config.DB_CLEANER_DOCS_LIMIT); | ||
|
||
dbg.log0(`DB_CLEANER: removed ${objects_to_remove.length + blocks_to_remove.length + filtered_chunks.length} documents from md-store`); | ||
} | ||
|
||
async function clean_md_store_objects(last_date_to_remove, limit) { | ||
dbg.log0('DB_CLEANER: checking md-store for documents deleted before', new Date(last_date_to_remove)); | ||
const objects_to_remove = await MDStore.instance().find_deleted_objects(last_date_to_remove, config.DB_CLEANER_DOCS_LIMIT); | ||
const objects_to_remove = await MDStore.instance().find_deleted_objects(last_date_to_remove, limit); | ||
dbg.log2('DB_CLEANER: list objects:', objects_to_remove); | ||
if (objects_to_remove.length) { | ||
if (objects_to_remove.length > config.MD_STORE_MAX_DELETED_OBJECTS_LIMIT) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are we adding this limit? why not deleting less? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the good number ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think number is arbitrary, but we can go with 10 or 20 for example |
||
await P.map_with_concurrency(10, objects_to_remove, obj => db_delete_object_parts(obj)); | ||
await MDStore.instance().db_delete_objects(objects_to_remove); | ||
} | ||
const blocks_to_remove = await MDStore.instance().find_deleted_blocks(last_date_to_remove, config.DB_CLEANER_DOCS_LIMIT); | ||
return objects_to_remove; | ||
} | ||
|
||
async function clean_md_store_blocks(last_date_to_remove, limit) { | ||
const blocks_to_remove = await MDStore.instance().find_deleted_blocks(last_date_to_remove, limit); | ||
dbg.log2('DB_CLEANER: list blocks:', blocks_to_remove); | ||
if (blocks_to_remove.length) await MDStore.instance().db_delete_blocks(blocks_to_remove); | ||
const chunks_to_remove = await MDStore.instance().find_deleted_chunks(last_date_to_remove, config.DB_CLEANER_DOCS_LIMIT); | ||
return blocks_to_remove; | ||
} | ||
|
||
async function clean_md_store_chunks(last_date_to_remove, limit) { | ||
const chunks_to_remove = await MDStore.instance().find_deleted_chunks(last_date_to_remove, limit); | ||
const filtered_chunks = chunks_to_remove.filter(async chunk => | ||
!(await MDStore.instance().has_any_blocks_for_chunk(chunk)) && | ||
!(await MDStore.instance().has_any_parts_for_chunk(chunk))); | ||
dbg.log2('DB_CLEANER: list chunks with no blocks and no parts to be removed from DB', filtered_chunks); | ||
if (filtered_chunks.length) await MDStore.instance().db_delete_chunks(filtered_chunks); | ||
dbg.log0(`DB_CLEANER: removed ${objects_to_remove.length + blocks_to_remove.length + filtered_chunks.length} documents from md-store`); | ||
return filtered_chunks; | ||
} | ||
|
||
async function db_delete_object_parts(id) { | ||
|
@@ -145,3 +161,4 @@ async function clean_system_store(last_date_to_remove) { | |
|
||
// EXPORTS | ||
exports.background_worker = background_worker; | ||
exports.clean_md_store_objects = clean_md_store_objects; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ const MDStore = require('../object_services/md_store').MDStore; | |
const system_store = require('../system_services/system_store').get_instance(); | ||
const system_utils = require('../utils/system_utils'); | ||
const map_deleter = require('../object_services/map_deleter'); | ||
const {clean_md_store_objects} = require('./db_cleaner'); | ||
const P = require('../../util/promise'); | ||
|
||
class ObjectsReclaimer { | ||
|
@@ -42,6 +43,9 @@ class ObjectsReclaimer { | |
if (has_errors) { | ||
return config.OBJECT_RECLAIMER_ERROR_DELAY; | ||
} | ||
|
||
await clean_md_store_objects(Date.now()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't think this belongs here... why should we run db_cleaner inside object_reclaimer - db_cleaner will run on objects with no regard to the list that was reclaimed (and of course, we don't want to db-delete objects that were just marked as deleted completely from the DB!). I think what we wanted here is a new functionality that for each of the objects, will check how many deleted objects we have with the same key and, if it's more than X - delete the older copies - @dannyzaken to keep me honest here... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The jira issue (https://issues.redhat.com/browse/DFBUGS-1339) is specifically mentioned that we can call clean the deleted objects from the md store in object reclaimer. Thought this is the place. @dannyzaken Please correct me here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vh05 I didn't intend for the description in Jira to be specific instructions on how to fix it. I wanted to provide some general context. |
||
|
||
return config.OBJECT_RECLAIMER_BATCH_DELAY; | ||
|
||
} | ||
|
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.
Did you rearrange the same code in smaller functions? I'm not sure if it's needed.
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. looking to clean only deleted md objects and other calls in the function not needed. Divided the function into 3 sub functions.