mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
Enhanced dbsim to store view and position in storage engine
Mimic real DBMS implementation by storing view and position into storage engine.
This commit is contained in:
@ -37,12 +37,13 @@ void db::storage_engine::transaction::apply(
|
||||
se_.bf_abort_some(transaction);
|
||||
}
|
||||
|
||||
void db::storage_engine::transaction::commit()
|
||||
void db::storage_engine::transaction::commit(const wsrep::gtid& gtid)
|
||||
{
|
||||
if (cc_)
|
||||
{
|
||||
wsrep::unique_lock<wsrep::mutex> lock(se_.mutex_);
|
||||
se_.transactions_.erase(cc_);
|
||||
se_.store_position(gtid);
|
||||
}
|
||||
cc_ = nullptr;
|
||||
}
|
||||
@ -80,3 +81,38 @@ void db::storage_engine::bf_abort_some(const wsrep::transaction& txc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void db::storage_engine::store_position(const wsrep::gtid& gtid)
|
||||
{
|
||||
validate_position(gtid);
|
||||
position_ = gtid;
|
||||
}
|
||||
|
||||
wsrep::gtid db::storage_engine::get_position() const
|
||||
{
|
||||
return position_;
|
||||
}
|
||||
|
||||
void db::storage_engine::store_view(const wsrep::view& view)
|
||||
{
|
||||
view_ = view;
|
||||
}
|
||||
|
||||
wsrep::view db::storage_engine::get_view() const
|
||||
{
|
||||
return view_;
|
||||
}
|
||||
|
||||
void db::storage_engine::validate_position(const wsrep::gtid& gtid) const
|
||||
{
|
||||
using std::rel_ops::operator<=;
|
||||
if (position_.id() == gtid.id() && gtid.seqno() <= position_.seqno())
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << "Invalid position submitted, position seqno "
|
||||
<< position_.seqno()
|
||||
<< " is greater than submitted seqno "
|
||||
<< gtid.seqno();
|
||||
throw wsrep::runtime_error(os.str());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user