mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
* Moved causal reads/gtid wait into server state interface
* Changed undefined seqno to be defined as -1
This commit is contained in:
@ -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";
|
||||
|
@ -89,7 +89,7 @@ int wsrep::transaction::start_replaying(const wsrep::ws_meta& ws_meta)
|
||||
assert(active());
|
||||
assert(client_state_.mode() == wsrep::client_state::m_high_priority);
|
||||
assert(state() == s_replaying);
|
||||
assert(ws_meta_.seqno().nil() == false);
|
||||
assert(ws_meta_.seqno().is_undefined() == false);
|
||||
certified_ = true;
|
||||
return 0;
|
||||
}
|
||||
|
@ -69,12 +69,12 @@ namespace
|
||||
|
||||
static inline wsrep_seqno_t seqno_to_native(wsrep::seqno seqno)
|
||||
{
|
||||
return (seqno.nil() ? WSREP_SEQNO_UNDEFINED : seqno.get());
|
||||
return seqno.get();
|
||||
}
|
||||
|
||||
static inline wsrep::seqno seqno_from_native(wsrep_seqno_t seqno)
|
||||
{
|
||||
return wsrep::seqno(seqno == WSREP_SEQNO_UNDEFINED ? 0 : seqno);
|
||||
return wsrep::seqno(seqno);
|
||||
}
|
||||
template <typename F, typename T>
|
||||
inline uint32_t map_one(const int flags, const F from,
|
||||
@ -520,9 +520,9 @@ int wsrep::wsrep_provider_v26::resync()
|
||||
return (wsrep_->resync(wsrep_) != WSREP_OK);
|
||||
}
|
||||
|
||||
int wsrep::wsrep_provider_v26::pause()
|
||||
wsrep::seqno wsrep::wsrep_provider_v26::pause()
|
||||
{
|
||||
return (wsrep_->pause(wsrep_) != WSREP_OK);
|
||||
return wsrep::seqno(wsrep_->pause(wsrep_));
|
||||
}
|
||||
|
||||
int wsrep::wsrep_provider_v26::resume()
|
||||
@ -633,6 +633,12 @@ wsrep::wsrep_provider_v26::replay(const wsrep::ws_handle& ws_handle,
|
||||
wsrep_->replay_trx(wsrep_, mwsh.native(), applier_ctx));
|
||||
}
|
||||
|
||||
enum wsrep::provider::status
|
||||
wsrep::wsrep_provider_v26::causal_read(int timeout) const
|
||||
{
|
||||
return map_return_value(wsrep_->sync_wait(wsrep_, 0, timeout, 0));
|
||||
}
|
||||
|
||||
int wsrep::wsrep_provider_v26::sst_sent(const wsrep::gtid& gtid, int err)
|
||||
{
|
||||
wsrep_gtid_t wsrep_gtid;
|
||||
|
@ -25,7 +25,7 @@ namespace wsrep
|
||||
|
||||
int desync();
|
||||
int resync();
|
||||
int pause();
|
||||
wsrep::seqno pause();
|
||||
int resume();
|
||||
|
||||
enum wsrep::provider::status run_applier(void*);
|
||||
@ -49,6 +49,9 @@ namespace wsrep
|
||||
const wsrep::ws_meta&);
|
||||
int release(wsrep::ws_handle&);
|
||||
enum wsrep::provider::status replay(const wsrep::ws_handle&, void*);
|
||||
|
||||
enum wsrep::provider::status causal_read(int) const;
|
||||
|
||||
int sst_sent(const wsrep::gtid&,int);
|
||||
int sst_received(const wsrep::gtid& gtid, int);
|
||||
|
||||
|
Reference in New Issue
Block a user