Take just main lock over the storage

This commit is contained in:
Josip Mrden 2024-02-27 13:22:47 +01:00
parent ffb5c751c8
commit d055495b44
2 changed files with 5 additions and 15 deletions

View File

@ -3190,20 +3190,12 @@ Callback SwitchMemoryDevice(storage::StorageMode current_mode, storage::StorageM
Callback DropGraph(memgraph::dbms::DatabaseAccess &db) {
Callback callback;
callback.fn = [&db]() mutable {
if (!db.try_exclusively([](auto &in) {
spdlog::info("Woohooooo!!");
auto current_storage_mode = in.GetStorageMode();
if (current_storage_mode != storage::StorageMode::IN_MEMORY_ANALYTICAL) {
throw utils::BasicException("Drop graph can not be used without IN_MEMORY_ANALYTICAL storage mode!");
}
std::this_thread::sleep_for(std::chrono::seconds(10));
in.UniqueAccess()->DropGraph();
})) { // Try exclusively failed
throw utils::BasicException(
"Drop graph command failed! Ensure that you're the only transaction currently running!");
auto storage = db->UniqueAccess();
auto storage_mode = db->GetStorageMode();
if (storage_mode != storage::StorageMode::IN_MEMORY_ANALYTICAL) {
throw utils::BasicException("Drop graph can not be used without IN_MEMORY_ANALYTICAL storage mode!");
}
storage->DropGraph();
return std::vector<std::vector<TypedValue>>();
};

View File

@ -2162,8 +2162,6 @@ void InMemoryStorage::FreeMemory(std::unique_lock<utils::ResourceLock> main_guar
}
void InMemoryStorage::DropGraph() {
std::unique_lock main_guard{main_lock_};
auto const unlink_remove_clear = [&](std::deque<Delta> &deltas) {
for (auto &delta : deltas) {
auto prev = delta.prev.Get();