From d47cc290ef745e1dbe9fe91ff6f3f5bc9fb15829 Mon Sep 17 00:00:00 2001 From: Marko Budiselic Date: Sat, 23 Apr 2022 19:28:52 +0200 Subject: [PATCH] Add complexity comments --- src/storage/v2/storage.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/storage/v2/storage.cpp b/src/storage/v2/storage.cpp index c0842dbee..3d2a23524 100644 --- a/src/storage/v2/storage.cpp +++ b/src/storage/v2/storage.cpp @@ -813,6 +813,7 @@ EdgeTypeId Storage::Accessor::NameToEdgeType(const std::string_view &name) { ret void Storage::Accessor::AdvanceCommand() { ++transaction_.command_id; } +// TODO(gitbuda): Consider adding addional Commit BasicResult because of replication failures. utils::BasicResult Storage::Accessor::Commit( const std::optional desired_commit_timestamp) { MG_ASSERT(is_transaction_active_, "The transaction is already terminated!"); @@ -893,6 +894,7 @@ utils::BasicResult Storage::Accessor::Commit( // Replica can log only the write transaction received from Main // so the Wal files are consistent if (storage_->replication_role_ == ReplicationRole::MAIN || desired_commit_timestamp.has_value()) { + // TODO(gitbuda): Possible to abort data operation because in this context there is an abort operation. storage_->AppendToWal(transaction_, *commit_timestamp_); } @@ -1124,6 +1126,14 @@ EdgeTypeId Storage::NameToEdgeType(const std::string_view &name) { return EdgeTypeId::FromUint(name_id_mapper_.NameToId(name)); } +// TODO(gitbuda): Hard to abort global operations in SYNC replication mode +// because there is no an abort op for that yet, one idea is to just apply +// reverse operation, e.g., CreateIndex <-> DropIndex. +// +// EDGE CASE 1: What if the first SYNC replica is alive, receives the delta +// object, while the second SYNC replica is dead? (replication clients are +// stored in a vector and accessed one by one) + bool Storage::CreateIndex(LabelId label, const std::optional desired_commit_timestamp) { std::unique_lock storage_guard(main_lock_); if (!indices_.label_index.CreateIndex(label, vertices_.access())) return false; @@ -1572,6 +1582,9 @@ void Storage::FinalizeWalFile() { } } +// TODO(gitbuda): Hard to abort data operation in SYNC replication mode because: +// * Just calling Abort inside AppendToWal for some reason causes infinite loop. + void Storage::AppendToWal(const Transaction &transaction, uint64_t final_commit_timestamp) { if (!InitializeWalFile()) return; // Traverse deltas and append them to the WAL file.