From 12935ebaab74115a598366869ad00d7cdab90fb5 Mon Sep 17 00:00:00 2001 From: Takayuki Tanabe Date: Wed, 19 Jul 2023 16:08:38 +0900 Subject: [PATCH] fix for https://github.com/project-tsurugi/tsurugi-issues/issues/323 --- .../interface/long_tx/search.cpp | 13 ++++++++----- .../complicated/tsurugi_issue323_test.cpp | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/concurrency_control/interface/long_tx/search.cpp b/src/concurrency_control/interface/long_tx/search.cpp index bc2de3fa3..0da76ce2d 100644 --- a/src/concurrency_control/interface/long_tx/search.cpp +++ b/src/concurrency_control/interface/long_tx/search.cpp @@ -42,7 +42,9 @@ extern Status version_traverse_and_read(session* const ti, // read latest version after version function if (is_latest) { - if (read_value) { ver->get_value(value); } + if (!f_check.get_absent()) { + if (read_value) { ver->get_value(value); } + } if (ver == rec_ptr->get_latest() && loadAcquire(&rec_ptr->get_tidw_ref().get_obj()) == f_check.get_obj()) { @@ -52,6 +54,7 @@ extern Status version_traverse_and_read(session* const ti, if (read_epoch > ti->get_read_version_max_epoch()) { ti->set_read_version_max_epoch(read_epoch); } + if (f_check.get_absent()) { return Status::WARN_NOT_FOUND; } return Status::OK; } /** @@ -68,7 +71,9 @@ extern Status version_traverse_and_read(session* const ti, if (ver == nullptr) { LOG(ERROR) << log_location_prefix << "unreachable path"; } - if (read_value) { ver->get_value(value); } + if (!ver->get_tid().get_absent()) { + if (read_value) { ver->get_value(value); } + } // check max epoch of read version auto read_epoch{ver->get_tid().get_epoch()}; if (read_epoch > ti->get_read_version_max_epoch()) { @@ -106,9 +111,7 @@ static Status check_before_execution(session* const ti, Storage const storage) { static Status hit_local_write_set(write_set_obj* const in_ws, Record* rec_ptr, std::string& value, bool const read_value) { - if (in_ws->get_op() == OP_TYPE::DELETE) { - return Status::WARN_NOT_FOUND; - } + if (in_ws->get_op() == OP_TYPE::DELETE) { return Status::WARN_NOT_FOUND; } if (read_value) { std::shared_lock lk{rec_ptr->get_mtx_value()}; in_ws->get_value(value); diff --git a/test/concurrency_control/complicated/tsurugi_issue323_test.cpp b/test/concurrency_control/complicated/tsurugi_issue323_test.cpp index ebd29847e..617688e07 100644 --- a/test/concurrency_control/complicated/tsurugi_issue323_test.cpp +++ b/test/concurrency_control/complicated/tsurugi_issue323_test.cpp @@ -55,7 +55,7 @@ void wait_start_tx(Token tx) { } } -TEST_P(tsurugi_issue323, DISABLED_must_not_read_inserting_record) { // NOLINT +TEST_P(tsurugi_issue323, must_not_read_inserting_record) { // NOLINT transaction_type write_tx_type = std::get<0>(GetParam()); transaction_type read_tx_type = std::get<1>(GetParam()); // setup