From 9e885939a356819178e6b51ebb976a4e002eaa05 Mon Sep 17 00:00:00 2001 From: sdong Date: Fri, 16 Jul 2021 19:28:01 -0700 Subject: [PATCH] Change to code for trimmed memtable history is to released outside DB mutex (#8530) Summary: Currently, the code shows that we delete memtables immedately after it is trimmed from history. Although it should never happen as the super version still holds the memtable, which is only switched after it, it feels a good practice not to do it, but use clean it up in the standard way: put it to WriteContext and clean it after DB mutex. Pull Request resolved: https://github.com/facebook/rocksdb/pull/8530 Test Plan: Run all existing tests. Reviewed By: ajkr Differential Revision: D29703410 fbshipit-source-id: 21d8068ac6377de4b6fa7a89697195742659fde4 --- db/db_impl/db_impl_write.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/db/db_impl/db_impl_write.cc b/db/db_impl/db_impl_write.cc index 9191b6ea6..66ade6b21 100644 --- a/db/db_impl/db_impl_write.cc +++ b/db/db_impl/db_impl_write.cc @@ -1651,12 +1651,7 @@ Status DBImpl::TrimMemtableHistory(WriteContext* context) { for (auto& cfd : cfds) { autovector to_delete; bool trimmed = cfd->imm()->TrimHistory( - &to_delete, cfd->mem()->ApproximateMemoryUsage()); - if (!to_delete.empty()) { - for (auto m : to_delete) { - delete m; - } - } + &context->memtables_to_free_, cfd->mem()->ApproximateMemoryUsage()); if (trimmed) { context->superversion_context.NewSuperVersion(); assert(context->superversion_context.new_superversion.get() != nullptr);