mdbx++: добавлена фиксация транзакции с получением информации о задержках.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2022-10-06 23:47:16 +03:00
parent 3579496945
commit bee7431f76
2 changed files with 30 additions and 2 deletions

View File

@ -3875,12 +3875,31 @@ public:
//----------------------------------------------------------------------------
/// \brief Abandon all the operations of the transaction instead of saving
/// them.
/// \brief Abandon all the operations of the transaction
/// instead of saving ones.
void abort();
/// \brief Commit all the operations of a transaction into the database.
void commit();
using commit_latency = MDBX_commit_latency;
/// \brief Commit all the operations of a transaction into the database
/// and collect latency information.
void commit(commit_latency *);
/// \brief Commit all the operations of a transaction into the database
/// and collect latency information.
void commit(commit_latency &latency) { return commit(&latency); }
/// \brief Commit all the operations of a transaction into the database
/// and return latency information.
/// \returns latency information of commit stages.
commit_latency commit_get_latency() {
commit_latency result;
commit(&result);
return result;
}
};
/// \brief Unmanaged cursor.

View File

@ -1424,6 +1424,15 @@ void txn_managed::commit() {
MDBX_CXX20_UNLIKELY err.throw_exception();
}
void txn_managed::commit(commit_latency *latency) {
const error err =
static_cast<MDBX_error_t>(::mdbx_txn_commit_ex(handle_, latency));
if (MDBX_LIKELY(err.code() != MDBX_THREAD_MISMATCH))
MDBX_CXX20_LIKELY handle_ = nullptr;
if (MDBX_UNLIKELY(err.code() != MDBX_SUCCESS))
MDBX_CXX20_UNLIKELY err.throw_exception();
}
//------------------------------------------------------------------------------
bool txn::drop_map(const char *name, bool throw_if_absent) {