From 6aa9e2a78b85127307e2b0433f95abe9ed170083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ante=20Pu=C5=A1i=C4=87?= Date: Thu, 8 Feb 2024 00:55:45 +0100 Subject: [PATCH] Rename the text search flag and set it to false by default --- src/flags/run_time_configurable.cpp | 14 +++++------ src/flags/run_time_configurable.hpp | 2 +- src/query/interpreter.cpp | 4 +-- src/query/plan/operator.cpp | 12 ++++----- src/query/procedure/mg_procedure_impl.cpp | 11 ++++++--- src/storage/v2/disk/storage.cpp | 4 +-- src/storage/v2/durability/durability.cpp | 2 +- src/storage/v2/durability/snapshot.cpp | 4 +-- src/storage/v2/indices/text_index.cpp | 30 +++++++++++------------ src/storage/v2/inmemory/storage.cpp | 4 +-- src/storage/v2/storage.cpp | 6 ++--- tests/e2e/text_search/workloads.yaml | 2 +- 12 files changed, 49 insertions(+), 46 deletions(-) diff --git a/src/flags/run_time_configurable.cpp b/src/flags/run_time_configurable.cpp index c6fe82451..1bf4ec2e9 100644 --- a/src/flags/run_time_configurable.cpp +++ b/src/flags/run_time_configurable.cpp @@ -55,7 +55,7 @@ DEFINE_double(query_execution_timeout_sec, 600, DEFINE_bool(cartesian_product_enabled, true, "Enable cartesian product expansion."); // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) -DEFINE_bool(text_search_enabled, true, "Enable text search."); +DEFINE_bool(experimental_text_search_enabled, false, "Enable experimental text search."); namespace { // Bolt server name @@ -76,14 +76,14 @@ constexpr auto kLogToStderrGFlagsKey = "also_log_to_stderr"; constexpr auto kCartesianProductEnabledSettingKey = "cartesian-product-enabled"; constexpr auto kCartesianProductEnabledGFlagsKey = "cartesian-product-enabled"; -constexpr auto kTextSearchEnabledSettingKey = "text-search-enabled"; -constexpr auto kTextSearchEnabledGFlagsKey = "text-search-enabled"; +constexpr auto kExperimentalTextSearchEnabledSettingKey = "experimental-text-search-enabled"; +constexpr auto kExperimentalTextSearchEnabledGFlagsKey = "experimental-text-search-enabled"; // NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables) // Local cache-like thing std::atomic execution_timeout_sec_; std::atomic cartesian_product_enabled_{true}; -std::atomic text_search_enabled_{true}; +std::atomic experimental_text_search_enabled_{true}; // NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables) auto ToLLEnum(std::string_view val) { @@ -195,8 +195,8 @@ void Initialize() { [](const std::string &val) { cartesian_product_enabled_ = val == "true"; }, ValidBoolStr); register_flag( - kTextSearchEnabledGFlagsKey, kTextSearchEnabledSettingKey, !kRestore, - [](const std::string &val) { text_search_enabled_ = val == "true"; }, ValidBoolStr); + kExperimentalTextSearchEnabledGFlagsKey, kExperimentalTextSearchEnabledSettingKey, !kRestore, + [](const std::string &val) { experimental_text_search_enabled_ = val == "true"; }, ValidBoolStr); } std::string GetServerName() { @@ -210,6 +210,6 @@ double GetExecutionTimeout() { return execution_timeout_sec_; } bool GetCartesianProductEnabled() { return cartesian_product_enabled_; } -bool GetTextSearchEnabled() { return text_search_enabled_; } +bool GetExperimentalTextSearchEnabled() { return experimental_text_search_enabled_; } } // namespace memgraph::flags::run_time diff --git a/src/flags/run_time_configurable.hpp b/src/flags/run_time_configurable.hpp index a06437100..8f0cdbf0d 100644 --- a/src/flags/run_time_configurable.hpp +++ b/src/flags/run_time_configurable.hpp @@ -47,6 +47,6 @@ bool GetCartesianProductEnabled(); * * @return bool */ -bool GetTextSearchEnabled(); +bool GetExperimentalTextSearchEnabled(); } // namespace memgraph::flags::run_time diff --git a/src/query/interpreter.cpp b/src/query/interpreter.cpp index 9f36105cc..ede978ff7 100644 --- a/src/query/interpreter.cpp +++ b/src/query/interpreter.cpp @@ -2532,7 +2532,7 @@ PreparedQuery PrepareIndexQuery(ParsedQuery parsed_query, bool in_explicit_trans if (index_type == IndexQuery::Type::LOOKUP) { maybe_index_error = properties.empty() ? dba->CreateIndex(label) : dba->CreateIndex(label, properties[0]); } else if (index_type == IndexQuery::Type::TEXT) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw QueryException("To use text indices, enable the text search feature."); } maybe_index_error = dba->CreateTextIndex(index_name, label); @@ -2562,7 +2562,7 @@ PreparedQuery PrepareIndexQuery(ParsedQuery parsed_query, bool in_explicit_trans if (index_type == IndexQuery::Type::LOOKUP) { maybe_index_error = properties.empty() ? dba->DropIndex(label) : dba->DropIndex(label, properties[0]); } else if (index_type == IndexQuery::Type::TEXT) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw QueryException("To use text indices, enable the text search feature."); } maybe_index_error = dba->DropTextIndex(index_name); diff --git a/src/query/plan/operator.cpp b/src/query/plan/operator.cpp index ccdbb59b6..6846834b4 100644 --- a/src/query/plan/operator.cpp +++ b/src/query/plan/operator.cpp @@ -251,7 +251,7 @@ VertexAccessor &CreateLocalVertex(const NodeCreationInfo &node_info, Frame *fram } MultiPropsInitChecked(&new_node, properties); - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { context.db_accessor->TextIndexAddVertex(&new_node); } @@ -2823,7 +2823,7 @@ bool SetProperty::SetPropertyCursor::Pull(Frame &frame, ExecutionContext &contex context.trigger_context_collector->RegisterSetObjectProperty(lhs.ValueVertex(), self_.property_, TypedValue{std::move(old_value)}, TypedValue{rhs}); } - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { auto new_node = lhs.ValueVertex(); context.db_accessor->TextIndexUpdateVertex(&new_node); } @@ -2983,7 +2983,7 @@ void SetPropertiesOnRecord(TRecordAccessor *record, const TypedValue &rhs, SetPr case TypedValue::Type::Vertex: { PropertiesMap new_properties = get_props(rhs.ValueVertex()); update_props(new_properties); - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { auto new_node = rhs.ValueVertex(); context->db_accessor->TextIndexUpdateVertex(&new_node); } @@ -3134,7 +3134,7 @@ bool SetLabels::SetLabelsCursor::Pull(Frame &frame, ExecutionContext &context) { } } - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { context.db_accessor->TextIndexUpdateVertex(&vertex); } @@ -3209,7 +3209,7 @@ bool RemoveProperty::RemovePropertyCursor::Pull(Frame &frame, ExecutionContext & } #endif remove_prop(&lhs.ValueVertex()); - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { auto &updated_vertex = lhs.ValueVertex(); context.db_accessor->TextIndexUpdateVertex(&updated_vertex); } @@ -3303,7 +3303,7 @@ bool RemoveLabels::RemoveLabelsCursor::Pull(Frame &frame, ExecutionContext &cont } } - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { context.db_accessor->TextIndexUpdateVertex(&vertex, self_.labels_); } diff --git a/src/query/procedure/mg_procedure_impl.cpp b/src/query/procedure/mg_procedure_impl.cpp index 52579a22d..1d25c51f6 100644 --- a/src/query/procedure/mg_procedure_impl.cpp +++ b/src/query/procedure/mg_procedure_impl.cpp @@ -1842,7 +1842,7 @@ mgp_error mgp_vertex_set_property(struct mgp_vertex *v, const char *property_nam const auto result = std::visit( [prop_key, property_value](auto &impl) { return impl.SetProperty(prop_key, ToPropertyValue(*property_value), - memgraph::flags::run_time::GetTextSearchEnabled()); + memgraph::flags::run_time::GetExperimentalTextSearchEnabled()); }, v->impl); if (result.HasError()) { @@ -1900,7 +1900,8 @@ mgp_error mgp_vertex_set_properties(struct mgp_vertex *v, struct mgp_map *proper v->graph->impl)); } - const auto result = v->getImpl().UpdateProperties(props, memgraph::flags::run_time::GetTextSearchEnabled()); + const auto result = + v->getImpl().UpdateProperties(props, memgraph::flags::run_time::GetExperimentalTextSearchEnabled()); if (result.HasError()) { switch (result.GetError()) { case memgraph::storage::Error::DELETED_OBJECT: @@ -1958,7 +1959,9 @@ mgp_error mgp_vertex_add_label(struct mgp_vertex *v, mgp_label label) { } const auto result = std::visit( - [label_id](auto &impl) { return impl.AddLabel(label_id, memgraph::flags::run_time::GetTextSearchEnabled()); }, + [label_id](auto &impl) { + return impl.AddLabel(label_id, memgraph::flags::run_time::GetExperimentalTextSearchEnabled()); + }, v->impl); if (result.HasError()) { @@ -2003,7 +2006,7 @@ mgp_error mgp_vertex_remove_label(struct mgp_vertex *v, mgp_label label) { } const auto result = std::visit( [label_id](auto &impl) { - return impl.RemoveLabel(label_id, memgraph::flags::run_time::GetTextSearchEnabled()); + return impl.RemoveLabel(label_id, memgraph::flags::run_time::GetExperimentalTextSearchEnabled()); }, v->impl); diff --git a/src/storage/v2/disk/storage.cpp b/src/storage/v2/disk/storage.cpp index f44ad2120..83baa32b9 100644 --- a/src/storage/v2/disk/storage.cpp +++ b/src/storage/v2/disk/storage.cpp @@ -1764,7 +1764,7 @@ utils::BasicResult DiskStorage::DiskAccessor::Co return StorageManipulationError{SerializationError{}}; } spdlog::trace("rocksdb: Commit successful"); - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { disk_storage->indices_.text_index_->Commit(); } @@ -1885,7 +1885,7 @@ void DiskStorage::DiskAccessor::Abort() { // query_plan_accumulate_aggregate.cpp transaction_.disk_transaction_->Rollback(); transaction_.disk_transaction_->ClearSnapshot(); - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { storage_->indices_.text_index_->Rollback(); } delete transaction_.disk_transaction_; diff --git a/src/storage/v2/durability/durability.cpp b/src/storage/v2/durability/durability.cpp index e47429205..b8afc7364 100644 --- a/src/storage/v2/durability/durability.cpp +++ b/src/storage/v2/durability/durability.cpp @@ -197,7 +197,7 @@ void RecoverIndicesAndStats(const RecoveredIndicesAndConstraints::IndicesMetadat } spdlog::info("Label+property indices statistics are recreated."); - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { // Recover text indices. spdlog::info("Recreating {} text indices from metadata.", indices_metadata.text.size()); auto *mem_text_index = static_cast(indices->text_index_.get()); diff --git a/src/storage/v2/durability/snapshot.cpp b/src/storage/v2/durability/snapshot.cpp index f83e856ed..6d80cd81a 100644 --- a/src/storage/v2/durability/snapshot.cpp +++ b/src/storage/v2/durability/snapshot.cpp @@ -1631,7 +1631,7 @@ RecoveredSnapshot LoadSnapshot(const std::filesystem::path &path, utils::SkipLis } // Recover text indices. - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { auto size = snapshot.ReadUint(); if (!size) throw RecoveryFailure("Couldn't recover the number of text indices!"); spdlog::info("Recovering metadata of {} text indices.", *size); @@ -2126,7 +2126,7 @@ void CreateSnapshot(Storage *storage, Transaction *transaction, const std::files } // Write text indices. - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { auto text = storage->indices_.text_index_->ListIndices(); snapshot.WriteUint(text.size()); for (const auto &item : text) { diff --git a/src/storage/v2/indices/text_index.cpp b/src/storage/v2/indices/text_index.cpp index 8ae806372..2cad78b49 100644 --- a/src/storage/v2/indices/text_index.cpp +++ b/src/storage/v2/indices/text_index.cpp @@ -19,7 +19,7 @@ namespace memgraph::storage { void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, const std::uint64_t transaction_start_timestamp, const std::vector &applicable_text_indices, bool skip_commit) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -72,7 +72,7 @@ void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, const std void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, const std::uint64_t transaction_start_timestamp) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -83,7 +83,7 @@ void TextIndex::AddNode(Vertex *vertex_after_update, Storage *storage, void TextIndex::UpdateNode(Vertex *vertex_after_update, Storage *storage, const std::uint64_t transaction_start_timestamp) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -96,7 +96,7 @@ void TextIndex::UpdateNode(Vertex *vertex_after_update, Storage *storage, void TextIndex::UpdateNode(Vertex *vertex_after_update, Storage *storage, const std::uint64_t transaction_start_timestamp, const std::vector &removed_labels) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -111,7 +111,7 @@ void TextIndex::UpdateNode(Vertex *vertex_after_update, Storage *storage, void TextIndex::RemoveNode(Vertex *vertex_after_update, const std::vector &applicable_text_indices) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -128,7 +128,7 @@ void TextIndex::RemoveNode(Vertex *vertex_after_update, } void TextIndex::RemoveNode(Vertex *vertex_after_update) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -139,7 +139,7 @@ void TextIndex::RemoveNode(Vertex *vertex_after_update) { void TextIndex::UpdateOnAddLabel(LabelId added_label, Vertex *vertex_after_update, Storage *storage, const std::uint64_t transaction_start_timestamp) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -152,7 +152,7 @@ void TextIndex::UpdateOnAddLabel(LabelId added_label, Vertex *vertex_after_updat void TextIndex::UpdateOnRemoveLabel(LabelId removed_label, Vertex *vertex_after_update, const std::uint64_t transaction_start_timestamp) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -164,7 +164,7 @@ void TextIndex::UpdateOnRemoveLabel(LabelId removed_label, Vertex *vertex_after_ void TextIndex::UpdateOnSetProperty(Vertex *vertex_after_update, Storage *storage, std::uint64_t transaction_start_timestamp) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -172,7 +172,7 @@ void TextIndex::UpdateOnSetProperty(Vertex *vertex_after_update, Storage *storag } std::vector TextIndex::GetApplicableTextIndices(const std::vector &labels) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -186,7 +186,7 @@ std::vector TextIndex::GetApplicableTextIndices(c } std::vector TextIndex::GetApplicableTextIndices(Vertex *vertex) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -200,7 +200,7 @@ std::vector TextIndex::GetApplicableTextIndices(V } bool TextIndex::CreateIndex(std::string index_name, LabelId label, memgraph::query::DbAccessor *db) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -294,7 +294,7 @@ bool TextIndex::CreateIndex(std::string index_name, LabelId label, memgraph::que bool TextIndex::RecoverIndex(std::string index_name, LabelId label, memgraph::utils::SkipList::Accessor vertices, NameIdMapper *name_id_mapper) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -392,7 +392,7 @@ bool TextIndex::RecoverIndex(std::string index_name, LabelId label, } bool TextIndex::DropIndex(std::string index_name) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } @@ -409,7 +409,7 @@ bool TextIndex::DropIndex(std::string index_name) { bool TextIndex::IndexExists(std::string index_name) const { return index_.contains(index_name); } std::vector TextIndex::Search(std::string index_name, std::string search_query) { - if (!flags::run_time::GetTextSearchEnabled()) { + if (!flags::run_time::GetExperimentalTextSearchEnabled()) { throw query::QueryException("To use text indices, enable the text search feature."); } diff --git a/src/storage/v2/inmemory/storage.cpp b/src/storage/v2/inmemory/storage.cpp index a910e5fba..26d5e1e1e 100644 --- a/src/storage/v2/inmemory/storage.cpp +++ b/src/storage/v2/inmemory/storage.cpp @@ -864,7 +864,7 @@ utils::BasicResult InMemoryStorage::InMemoryAcce return StorageManipulationError{*unique_constraint_violation}; } - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { mem_storage->indices_.text_index_->Commit(); } } @@ -1099,7 +1099,7 @@ void InMemoryStorage::InMemoryAccessor::Abort() { for (auto const &[property, prop_vertices] : property_cleanup) { storage_->indices_.AbortEntries(property, prop_vertices, transaction_.start_timestamp); } - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { storage_->indices_.text_index_->Rollback(); } diff --git a/src/storage/v2/storage.cpp b/src/storage/v2/storage.cpp index 3388900c2..9bdf2eb6f 100644 --- a/src/storage/v2/storage.cpp +++ b/src/storage/v2/storage.cpp @@ -149,7 +149,7 @@ Result> Storage::Accessor::DeleteVertex(VertexAcce return res.GetError(); } - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { storage_->indices_.text_index_->RemoveNode(vertex->vertex_); } @@ -190,7 +190,7 @@ Result>>> Stor return res.GetError(); } - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { storage_->indices_.text_index_->RemoveNode(vertex->vertex_); } @@ -282,7 +282,7 @@ Storage::Accessor::DetachDelete(std::vector nodes, std::vector return maybe_deleted_vertices.GetError(); } - if (flags::run_time::GetTextSearchEnabled()) { + if (flags::run_time::GetExperimentalTextSearchEnabled()) { for (auto *node : nodes_to_delete) { storage_->indices_.text_index_->RemoveNode(node); } diff --git a/tests/e2e/text_search/workloads.yaml b/tests/e2e/text_search/workloads.yaml index 7ad448670..8029627da 100644 --- a/tests/e2e/text_search/workloads.yaml +++ b/tests/e2e/text_search/workloads.yaml @@ -1,7 +1,7 @@ text_search_cluster: &text_search_cluster cluster: main: - args: ["--bolt-port", "7687", "--log-level=TRACE"] + args: ["--bolt-port", "7687", "--log-level=TRACE", "--experimental-text-search-enabled=true"] log_file: "text_search.log" setup_queries: [] validation_queries: []