Skip to content

Commit

Permalink
add documents, fix ltx read about read area violation, and add read a…
Browse files Browse the repository at this point in the history
…rea check for IUD writes
  • Loading branch information
thawk105 committed Aug 23, 2023
1 parent 0d3f577 commit bd2c708
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/shirakami/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ extern Status check_commit(Token token); // NOLINT
* @return Status::WARN_WRITE_WITHOUT_WP This function can't execute because
* this tx is long tx and didn't execute wp for @a storage.
* @return Status::OK success.
* @return Status::ERR_CC Error about concurrency control.
*/
extern Status delete_record(Token token, Storage storage, // NOLINT
std::string_view key);
Expand Down Expand Up @@ -211,6 +212,7 @@ extern Status init(database_options options = {}); // NOLINT
* should be equal or less than 30KB.
* @return Status::WARN_NOT_BEGIN The transaction was not begun.
* @return Status::WARN_STORAGE_NOT_FOUND @a storage is not found.
* @return Status::ERR_CC Error about concurrency control.
*/
extern Status insert(Token token, Storage storage,
std::string_view key, // NOLINT
Expand Down Expand Up @@ -251,6 +253,7 @@ extern Status leave(Token token); // NOLINT
* the fact that nothing was read is guaranteed by isolation.
* @return Status::WARN_PREMATURE In long or read only tx mode, it have to wait
* for some high priority transactions.
* @return Status::ERR_CC Error about concurrency control.
*/
extern Status open_scan(Token token, Storage storage, std::string_view l_key,
scan_endpoint l_end, std::string_view r_key,
Expand Down Expand Up @@ -393,6 +396,7 @@ extern Status tx_begin(transaction_options options = {}); // NOLINT
* should be equal or less than 30KB.
* @return Status::WARN_NOT_BEGIN The transaction was not begun.
* @return Status::WARN_NOT_FOUND The record is not found.
* @return Status::ERR_CC Error about concurrency control.
*/
extern Status update(Token token, Storage storage, std::string_view key,
std::string_view val); // NOLINT
Expand Down
1 change: 1 addition & 0 deletions src/concurrency_control/interface/delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "concurrency_control/include/tuple_local.h"
#include "concurrency_control/include/wp.h"
#include "concurrency_control/interface/include/helper.h"
#include "concurrency_control/interface/long_tx/include/long_tx.h"

#include "index/yakushima/include/interface.h"

Expand Down
9 changes: 9 additions & 0 deletions src/concurrency_control/interface/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,19 @@ Status check_before_write_ops(session* const ti, Storage const st,
return Status::WARN_WRITE_WITHOUT_WP;
}
if (op != OP_TYPE::UPSERT) {
// check for read area invalidation
auto rs = long_tx::check_read_area(ti, st);
if (rs == Status::ERR_READ_AREA_VIOLATION) {
std::unique_lock<std::mutex> lk{ti->get_mtx_termination()};
long_tx::abort(ti);
ti->set_result(reason_code::CC_LTX_READ_AREA_VIOLATION);
return rs;
}
// insert and delete with read
// may need forwarding
long_tx::wp_verify_and_forwarding(ti, wm, key);
}

} else if (ti->get_tx_type() ==
transaction_options::transaction_type::SHORT) {
// check wp
Expand Down
2 changes: 1 addition & 1 deletion src/concurrency_control/interface/long_tx/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static Status check_before_execution(session* const ti, Storage const storage) {
std::unique_lock<std::mutex> lk{ti->get_mtx_termination()};
long_tx::abort(ti);
ti->set_result(reason_code::CC_LTX_READ_AREA_VIOLATION);
return rs;
return Status::ERR_CC;
}

return Status::OK;
Expand Down
2 changes: 1 addition & 1 deletion src/concurrency_control/interface/scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Status open_scan_body(Token const token, Storage storage, // NOLINT
if (rs == Status::ERR_READ_AREA_VIOLATION) {
long_tx::abort(ti);
ti->set_result(reason_code::CC_LTX_READ_AREA_VIOLATION);
return rs;
return Status::ERR_CC;
}
}

Expand Down

0 comments on commit bd2c708

Please sign in to comment.