From a07d577bd5d1ff5d9600d4480dd59ff6a8be48a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ante=20Pu=C5=A1i=C4=87?= <ante.pusic@memgraph.io> Date: Mon, 5 Feb 2024 12:19:53 +0100 Subject: [PATCH] Fix snapshot recovery --- src/storage/v2/durability/durability.cpp | 1 + src/storage/v2/durability/snapshot.cpp | 36 ++++++++++++------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/storage/v2/durability/durability.cpp b/src/storage/v2/durability/durability.cpp index 724b3142d..e47429205 100644 --- a/src/storage/v2/durability/durability.cpp +++ b/src/storage/v2/durability/durability.cpp @@ -208,6 +208,7 @@ void RecoverIndicesAndStats(const RecoveredIndicesAndConstraints::IndicesMetadat name_id_mapper->IdToName(item.second.AsUint())); } } + spdlog::info("Text indices are recreated."); spdlog::info("Indices are recreated."); diff --git a/src/storage/v2/durability/snapshot.cpp b/src/storage/v2/durability/snapshot.cpp index 69afc8772..f83e856ed 100644 --- a/src/storage/v2/durability/snapshot.cpp +++ b/src/storage/v2/durability/snapshot.cpp @@ -993,24 +993,6 @@ RecoveredSnapshot LoadSnapshotVersion14(const std::filesystem::path &path, utils spdlog::info("Metadata of label+property indices are recovered."); } - // Recover text indices. - if (flags::run_time::GetTextSearchEnabled()) { - auto size = snapshot.ReadUint(); - if (!size) throw RecoveryFailure("Couldn't recover the number of text indices!"); - spdlog::info("Recovering metadata of {} text indices.", *size); - for (uint64_t i = 0; i < *size; ++i) { - auto index_name = snapshot.ReadString(); - if (!index_name.has_value()) throw RecoveryFailure("Couldn't read text index name!"); - auto label = snapshot.ReadUint(); - if (!label) throw RecoveryFailure("Couldn't read text index label!"); - AddRecoveredIndexConstraint(&indices_constraints.indices.text, {index_name.value(), get_label_from_id(*label)}, - "The text index already exists!"); - SPDLOG_TRACE("Recovered metadata of text index {} for :{}", index_name.value(), - name_id_mapper->IdToName(snapshot_id_map.at(*label))); - } - spdlog::info("Metadata of label+property indices are recovered."); - } - spdlog::info("Metadata of indices are recovered."); } @@ -1648,6 +1630,24 @@ RecoveredSnapshot LoadSnapshot(const std::filesystem::path &path, utils::SkipLis spdlog::info("Metadata of label+property indices are recovered."); } + // Recover text indices. + if (flags::run_time::GetTextSearchEnabled()) { + auto size = snapshot.ReadUint(); + if (!size) throw RecoveryFailure("Couldn't recover the number of text indices!"); + spdlog::info("Recovering metadata of {} text indices.", *size); + for (uint64_t i = 0; i < *size; ++i) { + auto index_name = snapshot.ReadString(); + if (!index_name.has_value()) throw RecoveryFailure("Couldn't read text index name!"); + auto label = snapshot.ReadUint(); + if (!label) throw RecoveryFailure("Couldn't read text index label!"); + AddRecoveredIndexConstraint(&indices_constraints.indices.text, {index_name.value(), get_label_from_id(*label)}, + "The text index already exists!"); + SPDLOG_TRACE("Recovered metadata of text index {} for :{}", index_name.value(), + name_id_mapper->IdToName(snapshot_id_map.at(*label))); + } + spdlog::info("Metadata of text indices are recovered."); + } + spdlog::info("Metadata of indices are recovered."); }