Skip to content

Commit

Permalink
fix: log message
Browse files Browse the repository at this point in the history
  • Loading branch information
thawk105 committed Jan 18, 2024
1 parent 48243fd commit c67cac4
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 42 deletions.
7 changes: 4 additions & 3 deletions src/concurrency_control/bg_work/bg_commit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void bg_commit::register_tx(Token token) {
auto* ti = static_cast<session*>(token);
// check from long
if (ti->get_tx_type() != transaction_options::transaction_type::LONG) {
LOG(ERROR) << log_location_prefix << "unexpected error";
LOG(ERROR) << log_location_prefix << "library programming error";
return;
}

Expand All @@ -64,7 +64,7 @@ void bg_commit::register_tx(Token token) {
std::make_tuple(ti->get_long_tx_id(), token));
if (!ret.second) {
// already exist
LOG(ERROR) << log_location_prefix << "unexpected error";
LOG(ERROR) << log_location_prefix << "library programming error";
}
}
}
Expand Down Expand Up @@ -115,7 +115,8 @@ void bg_commit::worker() {
transaction_options::transaction_type::LONG ||
!ti->get_requested_commit()) {
// not long or not requested commit.
LOG(ERROR) << log_location_prefix << "unexpected error. "
LOG(ERROR) << log_location_prefix
<< "library programming error. "
<< ti->get_tx_type() << ", " << std::boolalpha
<< ti->get_requested_commit()
<< ", tx_id:" << tx_id;
Expand Down
10 changes: 7 additions & 3 deletions src/concurrency_control/interface/delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ inline Status process_after_write(session* ti, write_set_obj* wso) {
Storage st = wso->get_storage();
Record* rec_ptr = wso->get_rec_ptr();
auto rs = ti->get_write_set().erase(wso);
if (rs != Status::OK) { LOG(ERROR) << "unexpected error: " << rs; }
if (rs != Status::OK) {
LOG(ERROR) << "library programming error. about strand?: " << rs;
}
if (!rc) {
// if this was update
ti->get_write_set().push({st, OP_TYPE::DELETE, rec_ptr}); // NOLINT
Expand All @@ -92,7 +94,9 @@ static void process_before_return_not_found(session* const ti,
wp::page_set_meta* psm{};
auto rc = wp::find_page_set_meta(storage, psm);
if (rc != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected error";
LOG(ERROR) << log_location_prefix
<< "unexpected error. library programming error or "
"usage error (mixed ddl and dml?)";
return;
}
// get range read by info
Expand Down Expand Up @@ -144,7 +148,7 @@ Status delete_record_body(Token token, Storage storage,
if (rc == Status::WARN_STORAGE_NOT_FOUND) {
return Status::WARN_STORAGE_NOT_FOUND;
}
LOG(ERROR) << log_location_prefix << "unexpected error: " << rc;
LOG(ERROR) << log_location_prefix << "library programming error: " << rc;
return Status::ERR_FATAL;
}

Expand Down
3 changes: 2 additions & 1 deletion src/concurrency_control/interface/insert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ Status insert_body(Token const token, Storage const storage, // NOLINT
// register read_by_set
register_read_if_ltx(ti, rec_ptr);
} else {
LOG(ERROR) << log_location_prefix << "unexpected path";
LOG(ERROR) << log_location_prefix
<< "library programming error";
return Status::ERR_FATAL;
}
// end: make read set
Expand Down
2 changes: 1 addition & 1 deletion src/concurrency_control/interface/long_tx/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void update_wp_at_commit(session* const ti, std::set<Storage> const& sts) {
itr = ti->get_wp_set().erase(itr);
continue;
}
LOG(ERROR) << log_location_prefix << "unexpected code path";
LOG(ERROR) << log_location_prefix << "library programming error";
itr->second->get_wp_lock().unlock();
}
++itr;
Expand Down
4 changes: 2 additions & 2 deletions src/concurrency_control/interface/long_tx/termination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ extern Status commit(session* const ti) {
goto END_COMMIT; // NOLINT
}
if (rc != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected error. " << rc;
LOG(ERROR) << log_location_prefix << "library programming error. " << rc;
return rc;
}

Expand Down Expand Up @@ -915,7 +915,7 @@ extern Status commit(session* const ti) {
// set transaction result
ti->set_result(reason_code::UNKNOWN);
} else {
LOG(ERROR) << "unexpected code path";
LOG(ERROR) << "library programming error.";
}

END_COMMIT: // NOLINT
Expand Down
2 changes: 1 addition & 1 deletion src/concurrency_control/interface/session_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Status leave_body(Token const token) { // NOLINT
if (itr.get_tx_type() !=
transaction_options::transaction_type::LONG) {
LOG(ERROR) << log_location_prefix
<< "unexpected error";
<< "library programming error";
}
// the ltx commit was submitted, wait result.
do {
Expand Down
20 changes: 11 additions & 9 deletions src/concurrency_control/interface/storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ void write_storage_metadata(std::string_view key, Storage st,
value.append(payload);
auto ret = tx_begin({s, transaction_options::transaction_type::SHORT});
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected error.";
LOG(ERROR) << log_location_prefix << "library programming error.";
}
ret = upsert(s, storage::meta_storage, key, value);
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unreachable path";
LOG(ERROR) << log_location_prefix << "library programming error.";
return;
}
if (commit(s) == Status::OK) {
leave(s);
return;
} // else
LOG(ERROR) << log_location_prefix << "unreachable path";
LOG(ERROR) << log_location_prefix << "library programming error";
}

void remove_storage_metadata(std::string_view key) {
Expand All @@ -59,7 +59,7 @@ void remove_storage_metadata(std::string_view key) {
std::string value{};
auto ret = tx_begin({s, transaction_options::transaction_type::SHORT});
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected error.";
LOG(ERROR) << log_location_prefix << "library programming error.";
}
ret = delete_record(s, storage::meta_storage, key);
if (ret != Status::OK) {
Expand All @@ -73,7 +73,7 @@ void remove_storage_metadata(std::string_view key) {
leave(s);
return;
} // else
LOG(ERROR) << log_location_prefix << "unreachable path";
LOG(ERROR) << log_location_prefix << "library programming error";
}

Status create_storage_body(std::string_view const key, Storage& storage,
Expand Down Expand Up @@ -148,7 +148,8 @@ Status get_storage_body(std::string_view const key, Storage& out) {
}

Status get_storage(std::string_view key, Storage& out) {
shirakami_log_entry << "get_storage " << shirakami_binstring(key) << ", out: " << out;
shirakami_log_entry << "get_storage " << shirakami_binstring(key)
<< ", out: " << out;
auto ret = get_storage_body(key, out);
shirakami_log_exit << "get_storage, " << ret;
return ret;
Expand Down Expand Up @@ -180,7 +181,7 @@ Status storage_get_options_body(Storage storage, storage_option& options) {
for (;;) {
ret = tx_begin({s, transaction_options::transaction_type::SHORT});
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected error.";
LOG(ERROR) << log_location_prefix << "library programming error.";
}
ret = search_key(s, storage::meta_storage, key, value);
if (ret != Status::OK) {
Expand Down Expand Up @@ -246,7 +247,8 @@ Status storage_set_options_body(Storage storage,
// store and log information
ret = tx_begin({s, transaction_options::transaction_type::SHORT});
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected error. " << ret;
LOG(ERROR) << log_location_prefix << "library programming error. "
<< ret;
}
ret = upsert(s, storage::meta_storage, key, value);
if (ret != Status::OK) {
Expand All @@ -257,7 +259,7 @@ Status storage_set_options_body(Storage storage,
leave(s);
return Status::OK;
} // else
LOG(ERROR) << log_location_prefix << "unreachable path";
LOG(ERROR) << log_location_prefix << "library programming error.";
return Status::ERR_FATAL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/concurrency_control/interface/termination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Status commit_body(Token const token, // NOLINT
// set about diagnostics. it must commit
ti->set_diag_tx_state_kind(TxState::StateKind::WAITING_DURABLE);
} else {
LOG(ERROR) << log_location_prefix << "unexpected error";
LOG(ERROR) << log_location_prefix << "library programming error";
return Status::ERR_FATAL;
}

Expand Down
4 changes: 3 additions & 1 deletion src/concurrency_control/interface/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ static void process_before_return_not_found(session* const ti,
wp::page_set_meta* psm{};
auto rc = wp::find_page_set_meta(storage, psm);
if (rc != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected error";
LOG(ERROR) << log_location_prefix
<< "library programming error or"
"usage error (mixed dml and ddl?)";
return;
}
// get range read by info
Expand Down
37 changes: 26 additions & 11 deletions src/concurrency_control/sequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,10 @@ Status sequence::sequence_map_push(SequenceId const id,
std::make_pair(epoch, std::make_tuple(version, value)));
if (!ret2.second) {
// This object must be operated by here.
LOG(ERROR) << log_location_prefix << "unexpected behavior";
LOG(ERROR) << log_location_prefix
<< "When it tried to manipulate an object inserted into "
"map, it was already manipulated by someone else.";
// maybe lack of mutex control
return Status::ERR_FATAL;
}
return Status::OK;
Expand Down Expand Up @@ -260,7 +263,7 @@ Status sequence::create_sequence(SequenceId* id) {
// generate sequence id
auto ret = sequence::generate_sequence_id(*id);
if (ret == Status::ERR_FATAL) {
LOG(ERROR) << log_location_prefix << "unexpected error";
LOG(ERROR) << log_location_prefix << "sequence id depletion";
return ret;
}

Expand Down Expand Up @@ -292,23 +295,30 @@ Status sequence::create_sequence(SequenceId* id) {
sizeof(initial_value));
ret = tx_begin({token, transaction_options::transaction_type::SHORT});
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected error. " << ret;
LOG(ERROR) << log_location_prefix
<< "There is no way that short tx will fail to start here. "
<< ret;
}
ret = upsert(token, storage::sequence_storage, key, value);
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected behavior: " << ret;
LOG(ERROR) << log_location_prefix
<< "There is no way that upsert will fail to start here: "
<< ret;
return Status::ERR_FATAL;
}
ret = commit(token);
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected behavior";
LOG(ERROR) << log_location_prefix
<< "There is no way that 1 upsert only"
"stx will fail here";
return Status::ERR_FATAL;
}

// cleanup transaction handle
ret = leave(token);
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected behavior";
LOG(ERROR) << log_location_prefix
<< "There is no way that leave will fail here";
return Status::ERR_FATAL;
}

Expand Down Expand Up @@ -394,31 +404,36 @@ Status sequence::delete_sequence(SequenceId const id) {
sizeof(value));
ret = tx_begin({token, transaction_options::transaction_type::SHORT});
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected error. " << ret;
LOG(ERROR) << log_location_prefix
<< "there is no way stx begin will fail here. " << ret;
}
ret = upsert(token, storage::sequence_storage, key, new_value);
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected behavior";
LOG(ERROR) << log_location_prefix
<< "there is no way stx's upsert will fail here";
return Status::ERR_FATAL;
}
ret = commit(token);
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected behavior";
LOG(ERROR) << log_location_prefix
<< "there is no way commit will fail here.";
return Status::ERR_FATAL;
}

// update sequence object to deleted
auto epoch = static_cast<session*>(token)->get_mrc_tid().get_epoch();
ret = sequence::sequence_map_update(id, epoch, version, value);
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unreachable path";
LOG(ERROR) << log_location_prefix
<< "there is no way sequence map update will fail here.";
return Status::ERR_FATAL;
}

// cleanup transaction handle
ret = leave(token);
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected behavior";
LOG(ERROR) << log_location_prefix
<< "there is no way leave will fail here.";
return Status::ERR_FATAL;
}

Expand Down
10 changes: 6 additions & 4 deletions src/concurrency_control/transaction_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ Status check_tx_state_body(TxStateHandle handle, TxState& out) {
out.set_kind(TxState::StateKind::DURABLE); // for external
}
#else
// if no logging, it must not be waiting_durable status
LOG(ERROR) << log_location_prefix << "unexpected path";
LOG(ERROR)
<< log_location_prefix
<< "if no logging, it must not be waiting_durabule status";
return Status::ERR_FATAL;
#endif
}
Expand All @@ -133,8 +134,9 @@ Status check_tx_state_body(TxStateHandle handle, TxState& out) {
out.set_kind(TxState::StateKind::DURABLE); // for external
}
#else
// if no logging, it must not be waiting_durable status
LOG(ERROR) << log_location_prefix << "unexpected path";
LOG(ERROR)
<< log_location_prefix
<< "if no logging, it must not be waiting_durable status";
return Status::ERR_FATAL;
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/concurrency_control/wp_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ wp_meta::register_wp_result_and_remove_wp(wp_result_elem_type const& elem) {
return Status::OK;
}
}
LOG(ERROR) << log_location_prefix << "unexpected code path";
LOG(ERROR) << log_location_prefix << "concurrent program error";
return Status::WARN_NOT_FOUND;
}

Expand Down
12 changes: 8 additions & 4 deletions src/datastore/limestone/datastore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ void recovery_from_datastore() {
if (storage::key_handle_map_push_storage(key, st2) !=
Status::OK) {
// Does DML create key handle map entry?
LOG(ERROR) << log_location_prefix << "unexpected error";
LOG(ERROR) << log_location_prefix
<< "library programming error.";
return;
}
} else {
Expand All @@ -148,7 +149,8 @@ void recovery_from_datastore() {
* shirakami::storage::exist_storage(st2) said not exist,
* but it can't register_storage.
*/
LOG(ERROR) << log_location_prefix << "unexpected error";
LOG(ERROR) << log_location_prefix
<< "library programming error";
return;
}
if (storage::key_handle_map_push_storage(key, st2) !=
Expand All @@ -158,7 +160,8 @@ void recovery_from_datastore() {
* shirakami::register_storage(st2, {id, payload}) was
* succeeded but it can't create entry of this map.
*/
LOG(ERROR) << log_location_prefix << "unexpected error";
LOG(ERROR) << log_location_prefix
<< "library programming error";
return;
}
put_data(storage::meta_storage, key, new_value);
Expand All @@ -176,7 +179,8 @@ void recovery_from_datastore() {
sizeof(version));
auto ret = sequence::sequence_map_push(id, 0, version, value);
if (ret != Status::OK) {
LOG(ERROR) << log_location_prefix << "unexpected error";
LOG(ERROR) << log_location_prefix
<< "library programming error";
return;
}
} else {
Expand Down

0 comments on commit c67cac4

Please sign in to comment.