1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-21 12:22:06 +03:00

* Moved causal reads/gtid wait into server state interface

* Changed undefined seqno to be defined as -1
This commit is contained in:
Teemu Ollakka
2018-06-21 10:37:55 +03:00
parent ef0fb72b73
commit 3a8861b26b
12 changed files with 167 additions and 65 deletions

View File

@ -77,6 +77,41 @@ void wsrep::server_state::wait_until_state(
cond_.notify_all();
}
void wsrep::server_state::last_committed_gtid(const wsrep::gtid& gtid)
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
assert(last_committed_gtid_.is_undefined() ||
last_committed_gtid_.seqno() + 1 == gtid.seqno());
last_committed_gtid_ = gtid;
cond_.notify_all();
}
wsrep::gtid wsrep::server_state::last_committed_gtid() const
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
return last_committed_gtid_;
}
int wsrep::server_state::wait_for_gtid(const wsrep::gtid& gtid) const
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
if (gtid.id() != last_committed_gtid_.id())
{
return 1;
}
while (last_committed_gtid_.seqno() < gtid.seqno())
{
cond_.wait(lock);
}
return 0;
}
enum wsrep::provider::status
wsrep::server_state::causal_read(int timeout) const
{
return provider_->causal_read(timeout);
}
void wsrep::server_state::on_connect()
{
wsrep::log() << "Server " << name_ << " connected to cluster";