tx::Engine - commit log encapsulation
Reviewers: buda Reviewed By: buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D460
This commit is contained in:
parent
f7d540829a
commit
9e6260d0c3
src
@ -265,7 +265,7 @@ class GraphDbAccessor {
|
||||
auto wait_transaction = db_.tx_engine.Begin();
|
||||
for (auto id : wait_transaction->snapshot()) {
|
||||
if (id == transaction_->id_) continue;
|
||||
while (wait_transaction->engine_.clog_.fetch_info(id).is_active())
|
||||
while (wait_transaction->engine_.clog().fetch_info(id).is_active())
|
||||
// TODO reconsider this constant, currently rule-of-thumb chosen
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(100));
|
||||
}
|
||||
|
@ -129,8 +129,8 @@ class Record : public Version<T> {
|
||||
// snapshot (consequently also not in the snapshots of
|
||||
// newer transactions)
|
||||
return (exp_id != 0 && exp_id < snapshot.back() &&
|
||||
engine.clog_.is_committed(exp_id) && !snapshot.contains(exp_id)) ||
|
||||
engine.clog_.is_aborted(tx.cre());
|
||||
engine.clog().is_committed(exp_id) && !snapshot.contains(exp_id)) ||
|
||||
engine.clog().is_aborted(tx.cre());
|
||||
}
|
||||
|
||||
// TODO: Test this
|
||||
@ -230,7 +230,7 @@ class Record : public Version<T> {
|
||||
if (!hint_bits.is_unknown()) return hint_bits.is_committed();
|
||||
|
||||
// if hints are not set consult the commit log
|
||||
auto info = engine.clog_.fetch_info(id);
|
||||
auto info = engine.clog().fetch_info(id);
|
||||
|
||||
// committed
|
||||
if (info.is_committed()) return hints.set_committed(), true;
|
||||
|
@ -31,17 +31,21 @@ class CommitLog {
|
||||
|
||||
CommitLog operator=(CommitLog) = delete;
|
||||
|
||||
Info fetch_info(transaction_id_t id) { return Info{log.at(2 * id, 2)}; }
|
||||
Info fetch_info(transaction_id_t id) const { return Info{log.at(2 * id, 2)}; }
|
||||
|
||||
bool is_active(transaction_id_t id) { return fetch_info(id).is_active(); }
|
||||
bool is_active(transaction_id_t id) const {
|
||||
return fetch_info(id).is_active();
|
||||
}
|
||||
|
||||
bool is_committed(transaction_id_t id) {
|
||||
bool is_committed(transaction_id_t id) const {
|
||||
return fetch_info(id).is_committed();
|
||||
}
|
||||
|
||||
void set_committed(transaction_id_t id) { log.set(2 * id); }
|
||||
|
||||
bool is_aborted(transaction_id_t id) { return fetch_info(id).is_aborted(); }
|
||||
bool is_aborted(transaction_id_t id) const {
|
||||
return fetch_info(id).is_aborted();
|
||||
}
|
||||
|
||||
void set_aborted(transaction_id_t id) { log.set(2 * id + 1); }
|
||||
|
||||
|
@ -137,15 +137,13 @@ class Engine : Lockable<SpinLock> {
|
||||
return active_.size();
|
||||
}
|
||||
|
||||
// TODO make this private and expose "const CommitLog"
|
||||
// through a getter. To do that you need to make the
|
||||
// appropriate CommitLog functions const. To do THAT,
|
||||
// you need to make appropriate DynamicBitset functions
|
||||
// const. While doing that, clean the DynamicBitset up.
|
||||
/** Commit log of this engine */
|
||||
CommitLog clog_;
|
||||
/** Returns this engine's commit log */
|
||||
auto &clog() const { return clog_; }
|
||||
|
||||
private:
|
||||
// commit log of this engine
|
||||
CommitLog clog_;
|
||||
|
||||
// Performs cleanup common to ending the transaction
|
||||
// with either commit or abort
|
||||
void Finalize(const Transaction &t) {
|
||||
|
Loading…
Reference in New Issue
Block a user