Add a global storage lock in storage v2
Reviewers: mferencevic, teon.banek Reviewed By: mferencevic, teon.banek Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2202
This commit is contained in:
parent
5a3e98badd
commit
08bf993a47
@ -26,7 +26,8 @@ Storage::Accessor::Accessor(Storage *storage, uint64_t transaction_id,
|
|||||||
: storage_(storage),
|
: storage_(storage),
|
||||||
transaction_(transaction_id, start_timestamp),
|
transaction_(transaction_id, start_timestamp),
|
||||||
is_transaction_starter_(true),
|
is_transaction_starter_(true),
|
||||||
is_transaction_active_(true) {}
|
is_transaction_active_(true),
|
||||||
|
storage_guard_(storage_->main_lock_) {}
|
||||||
|
|
||||||
Storage::Accessor::Accessor(Accessor &&other) noexcept
|
Storage::Accessor::Accessor(Accessor &&other) noexcept
|
||||||
: storage_(other.storage_),
|
: storage_(other.storage_),
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <shared_mutex>
|
||||||
|
|
||||||
#include "storage/v2/commit_log.hpp"
|
#include "storage/v2/commit_log.hpp"
|
||||||
#include "storage/v2/edge.hpp"
|
#include "storage/v2/edge.hpp"
|
||||||
@ -11,6 +12,7 @@
|
|||||||
#include "storage/v2/transaction.hpp"
|
#include "storage/v2/transaction.hpp"
|
||||||
#include "storage/v2/vertex.hpp"
|
#include "storage/v2/vertex.hpp"
|
||||||
#include "storage/v2/vertex_accessor.hpp"
|
#include "storage/v2/vertex_accessor.hpp"
|
||||||
|
#include "utils/rw_lock.hpp"
|
||||||
#include "utils/scheduler.hpp"
|
#include "utils/scheduler.hpp"
|
||||||
#include "utils/skip_list.hpp"
|
#include "utils/skip_list.hpp"
|
||||||
|
|
||||||
@ -99,6 +101,8 @@ class Storage final {
|
|||||||
Transaction transaction_;
|
Transaction transaction_;
|
||||||
bool is_transaction_starter_;
|
bool is_transaction_starter_;
|
||||||
bool is_transaction_active_;
|
bool is_transaction_active_;
|
||||||
|
|
||||||
|
std::shared_lock<utils::RWLock> storage_guard_;
|
||||||
};
|
};
|
||||||
|
|
||||||
Accessor Access();
|
Accessor Access();
|
||||||
@ -106,6 +110,14 @@ class Storage final {
|
|||||||
private:
|
private:
|
||||||
void CollectGarbage();
|
void CollectGarbage();
|
||||||
|
|
||||||
|
// Main storage lock.
|
||||||
|
//
|
||||||
|
// Accessors take a shared lock when starting, so it is possible to block
|
||||||
|
// creation of new accessors by taking a unique lock. This is used when
|
||||||
|
// building a label-property index because it is much simpler to do when there
|
||||||
|
// are no parallel reads and writes.
|
||||||
|
utils::RWLock main_lock_{utils::RWLock::Priority::WRITE};
|
||||||
|
|
||||||
// Main object storage
|
// Main object storage
|
||||||
utils::SkipList<storage::Vertex> vertices_;
|
utils::SkipList<storage::Vertex> vertices_;
|
||||||
utils::SkipList<storage::Edge> edges_;
|
utils::SkipList<storage::Edge> edges_;
|
||||||
|
Loading…
Reference in New Issue
Block a user