Take just main lock over the storage
This commit is contained in:
parent
ffb5c751c8
commit
d055495b44
@ -3190,20 +3190,12 @@ Callback SwitchMemoryDevice(storage::StorageMode current_mode, storage::StorageM
|
|||||||
Callback DropGraph(memgraph::dbms::DatabaseAccess &db) {
|
Callback DropGraph(memgraph::dbms::DatabaseAccess &db) {
|
||||||
Callback callback;
|
Callback callback;
|
||||||
callback.fn = [&db]() mutable {
|
callback.fn = [&db]() mutable {
|
||||||
if (!db.try_exclusively([](auto &in) {
|
auto storage = db->UniqueAccess();
|
||||||
spdlog::info("Woohooooo!!");
|
auto storage_mode = db->GetStorageMode();
|
||||||
auto current_storage_mode = in.GetStorageMode();
|
if (storage_mode != storage::StorageMode::IN_MEMORY_ANALYTICAL) {
|
||||||
if (current_storage_mode != storage::StorageMode::IN_MEMORY_ANALYTICAL) {
|
throw utils::BasicException("Drop graph can not be used without IN_MEMORY_ANALYTICAL storage mode!");
|
||||||
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!");
|
|
||||||
}
|
}
|
||||||
|
storage->DropGraph();
|
||||||
return std::vector<std::vector<TypedValue>>();
|
return std::vector<std::vector<TypedValue>>();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2162,8 +2162,6 @@ void InMemoryStorage::FreeMemory(std::unique_lock<utils::ResourceLock> main_guar
|
|||||||
}
|
}
|
||||||
|
|
||||||
void InMemoryStorage::DropGraph() {
|
void InMemoryStorage::DropGraph() {
|
||||||
std::unique_lock main_guard{main_lock_};
|
|
||||||
|
|
||||||
auto const unlink_remove_clear = [&](std::deque<Delta> &deltas) {
|
auto const unlink_remove_clear = [&](std::deque<Delta> &deltas) {
|
||||||
for (auto &delta : deltas) {
|
for (auto &delta : deltas) {
|
||||||
auto prev = delta.prev.Get();
|
auto prev = delta.prev.Get();
|
||||||
|
Loading…
Reference in New Issue
Block a user