Support durability recovery on worker (specifically indexes)
Summary: A hack worthy of young master Gleich. I *think* it's correct though, and the tests pass. End-to-end cluster recovery testing will be written and tried out by @mculinovic Reviewers: dgleich, mculinovic Reviewed By: dgleich Subscribers: pullbot, mculinovic Differential Revision: https://phabricator.memgraph.io/D1163
This commit is contained in:
parent
25dae811c9
commit
8db0fe84b2
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <experimental/filesystem>
|
||||
|
||||
#include "data_structures/concurrent/concurrent_map.hpp"
|
||||
#include "data_structures/concurrent/concurrent_set.hpp"
|
||||
#include "database/indexes/key_index.hpp"
|
||||
@ -13,6 +15,14 @@ namespace distributed {
|
||||
class IndexRpcServer;
|
||||
};
|
||||
|
||||
namespace database {
|
||||
class GraphDb;
|
||||
};
|
||||
|
||||
namespace durability {
|
||||
bool Recover(const std::experimental::filesystem::path &, database::GraphDb &);
|
||||
};
|
||||
|
||||
namespace database {
|
||||
|
||||
/** A data structure containing the main data members of a graph database. */
|
||||
@ -41,6 +51,8 @@ class Storage {
|
||||
friend class GraphDbAccessor;
|
||||
friend class StorageGc;
|
||||
friend class distributed::IndexRpcServer;
|
||||
friend bool durability::Recover(const std::experimental::filesystem::path &,
|
||||
database::GraphDb &);
|
||||
|
||||
gid::Generator vertex_generator_;
|
||||
gid::Generator edge_generator_;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <unordered_map>
|
||||
|
||||
#include "database/graph_db_accessor.hpp"
|
||||
#include "database/indexes/label_property_index.hpp"
|
||||
#include "durability/hashed_file_reader.hpp"
|
||||
#include "durability/paths.hpp"
|
||||
#include "durability/snapshot_decoded_value.hpp"
|
||||
@ -335,10 +336,14 @@ bool Recover(const fs::path &durability_dir, database::GraphDb &db) {
|
||||
|
||||
// Index recovery.
|
||||
database::GraphDbAccessor db_accessor_indices{db};
|
||||
for (const auto &label_prop : recovery_data.indexes)
|
||||
db_accessor_indices.BuildIndex(
|
||||
for (const auto &label_prop : recovery_data.indexes) {
|
||||
const database::LabelPropertyIndex::Key key{
|
||||
db_accessor_indices.Label(label_prop.first),
|
||||
db_accessor_indices.Property(label_prop.second));
|
||||
db_accessor_indices.Property(label_prop.second)};
|
||||
db_accessor_indices.db().storage().label_property_index_.CreateIndex(key);
|
||||
db_accessor_indices.PopulateIndex(key);
|
||||
db_accessor_indices.EnableIndex(key);
|
||||
}
|
||||
db_accessor_indices.Commit();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user