mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
MDEV-36551: Add interface to report wsrep state change in Galera
This commit is contained in:
committed by
Jan Lindström
parent
14ce8cab76
commit
a2d7d89c1d
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
* Copyright (C) 2018-2025 Codership Oy <info@codership.com>
|
||||
*
|
||||
* This file is part of wsrep-lib.
|
||||
*
|
||||
@ -94,6 +94,8 @@ namespace db
|
||||
|
||||
void debug_sync(const char*) override { }
|
||||
void debug_crash(const char*) override { }
|
||||
void notify_state_change() override { }
|
||||
|
||||
private:
|
||||
db::client& client_;
|
||||
wsrep::client_state& client_state_;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
* Copyright (C) 2018-2025 Codership Oy <info@codership.com>
|
||||
*
|
||||
* This file is part of wsrep-lib.
|
||||
*
|
||||
@ -227,7 +227,13 @@ namespace wsrep
|
||||
* been enabled.
|
||||
*/
|
||||
virtual void debug_crash(const char* crash_point) = 0;
|
||||
|
||||
//
|
||||
// Notify state change interface
|
||||
//
|
||||
virtual void notify_state_change() = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // WSREP_CLIENT_SERVICE_HPP
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2019 Codership Oy <info@codership.com>
|
||||
* Copyright (C) 2018-2025 Codership Oy <info@codership.com>
|
||||
*
|
||||
* This file is part of wsrep-lib.
|
||||
*
|
||||
@ -1047,6 +1047,7 @@ void wsrep::client_state::state(
|
||||
}
|
||||
state_hist_.push_back(state_);
|
||||
state_ = state;
|
||||
client_service_.notify_state_change();
|
||||
if (state_hist_.size() > 10)
|
||||
{
|
||||
state_hist_.erase(state_hist_.begin());
|
||||
@ -1076,6 +1077,7 @@ void wsrep::client_state::mode(
|
||||
assert(0);
|
||||
}
|
||||
mode_ = mode;
|
||||
client_service_.notify_state_change();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
* Copyright (C) 2018-2025 Codership Oy <info@codership.com>
|
||||
*
|
||||
* This file is part of wsrep-lib.
|
||||
*
|
||||
@ -138,6 +138,7 @@ int wsrep::transaction::start_transaction(
|
||||
state_hist_.clear();
|
||||
ws_handle_ = wsrep::ws_handle(id);
|
||||
flags(wsrep::provider::flag::start_transaction);
|
||||
client_service_.notify_state_change();
|
||||
switch (client_state_.mode())
|
||||
{
|
||||
case wsrep::client_state::m_high_priority:
|
||||
@ -167,6 +168,7 @@ int wsrep::transaction::start_transaction(
|
||||
id_ = ws_meta.transaction_id();
|
||||
assert(client_state_.mode() == wsrep::client_state::m_high_priority);
|
||||
state_ = s_executing;
|
||||
client_service_.notify_state_change();
|
||||
state_hist_.clear();
|
||||
ws_handle_ = ws_handle;
|
||||
ws_meta_ = ws_meta;
|
||||
@ -1140,6 +1142,7 @@ void wsrep::transaction::clone_for_replay(const wsrep::transaction& other)
|
||||
ws_meta_ = other.ws_meta_;
|
||||
streaming_context_ = other.streaming_context_;
|
||||
state_ = s_replaying;
|
||||
client_service_.notify_state_change();
|
||||
}
|
||||
|
||||
void wsrep::transaction::assign_xid(const wsrep::xid& xid)
|
||||
@ -1383,6 +1386,7 @@ void wsrep::transaction::state(
|
||||
state_hist_.erase(state_hist_.begin());
|
||||
}
|
||||
state_ = next_state;
|
||||
client_service_.notify_state_change();
|
||||
|
||||
if (state_ == s_must_replay)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 Codership Oy <info@codership.com>
|
||||
* Copyright (C) 2018-2025 Codership Oy <info@codership.com>
|
||||
*
|
||||
* This file is part of wsrep-lib.
|
||||
*
|
||||
@ -211,6 +211,10 @@ namespace wsrep
|
||||
// Not going to do this while unit testing
|
||||
}
|
||||
|
||||
void notify_state_change() WSREP_OVERRIDE
|
||||
{
|
||||
// Not going to do this while unit testing
|
||||
}
|
||||
|
||||
//
|
||||
// Knobs to tune the behavior
|
||||
|
Reference in New Issue
Block a user