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

Implemented SR transaction rollbacking during configuration changes.

SR tranasctions are BF aborted or rolled back on primary view
changes according to the following rules:
* Ongoing local SR transactions are BF aborted if the processing
  server is not found from the current view.
* All remote SR transactions whose origin server is not included in the
  current view are rolled back.
This commit is contained in:
Teemu Ollakka
2018-07-14 16:11:13 +03:00
parent 13487781d8
commit 86472ee420
6 changed files with 265 additions and 44 deletions

View File

@ -5,6 +5,8 @@
#ifndef WSREP_CLIENT_ID_HPP
#define WSREP_CLIENT_ID_HPP
#include <ostream>
namespace wsrep
{
class client_id
@ -20,9 +22,19 @@ namespace wsrep
{ }
type get() const { return id_; }
static type undefined() { return -1; }
bool operator<(const client_id& other) const
{
return (id_ < other.id_);
}
private:
type id_;
};
static inline std::ostream& operator<<(
std::ostream& os, const wsrep::client_id& client_id)
{
return (os << client_id.get());
}
}
#endif // WSREP_CLIENT_ID_HPP

View File

@ -212,6 +212,15 @@ namespace wsrep
*/
enum rollback_mode rollback_mode() const { return rollback_mode_; }
/**
* Registers a streaming client.
*/
void start_streaming_client(wsrep::client_state* client_state);
void convert_streaming_client_to_applier(
wsrep::client_state* client_state);
void stop_streaming_client(wsrep::client_state* client_state);
void start_streaming_applier(
const wsrep::id&,
const wsrep::transaction_id&,
@ -278,7 +287,8 @@ namespace wsrep
* @params view wsrep::view object which holds the new view
* information.
*/
void on_view(const wsrep::view& view);
void on_view(const wsrep::view& view,
wsrep::high_priority_service*);
/**
* A method which will be called when the server
@ -533,6 +543,7 @@ namespace wsrep
, desync_count_()
, pause_count_()
, pause_seqno_()
, streaming_clients_()
, streaming_appliers_()
, provider_()
, name_(name)
@ -557,6 +568,11 @@ namespace wsrep
void resync(wsrep::unique_lock<wsrep::mutex>&);
void state(wsrep::unique_lock<wsrep::mutex>&, enum state);
void wait_until_state(wsrep::unique_lock<wsrep::mutex>&, enum state) const;
// Close SR transcations whose origin is outside of current
// cluster view.
void close_foreign_sr_transactions(
wsrep::unique_lock<wsrep::mutex>&,
wsrep::high_priority_service&);
wsrep::mutex& mutex_;
wsrep::condition_variable& cond_;
@ -572,7 +588,25 @@ namespace wsrep
size_t desync_count_;
size_t pause_count_;
wsrep::seqno pause_seqno_;
typedef std::map<std::pair<wsrep::id, wsrep::transaction_id>, wsrep::high_priority_service*> streaming_appliers_map;
typedef std::map<wsrep::client_id, wsrep::client_state*>
streaming_clients_map;
streaming_clients_map streaming_clients_;
typedef std::map<std::pair<wsrep::id, wsrep::transaction_id>,
wsrep::high_priority_service*> streaming_appliers_map;
class server_id_cmp
{
public:
server_id_cmp(const wsrep::id& server_id)
: server_id_(server_id)
{ }
bool operator()(const std::vector<wsrep::view::member>::value_type& vt) const
{
return (vt.id() == server_id_);
}
private:
wsrep::id server_id_;
};
streaming_appliers_map streaming_appliers_;
wsrep::provider* provider_;
std::string name_;