mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-27 09:01:50 +03:00
* Added size exceeded error code
* Return provider status from selected client_state calls * Added more methods to provider interface
This commit is contained in:
@ -30,6 +30,7 @@ namespace wsrep
|
||||
e_error_during_commit,
|
||||
e_deadlock_error,
|
||||
e_interrupted_error,
|
||||
e_size_exceeded_error,
|
||||
e_append_fragment_error
|
||||
};
|
||||
|
||||
@ -41,6 +42,7 @@ namespace wsrep
|
||||
case e_error_during_commit: return "error_during_commit";
|
||||
case e_deadlock_error: return "deadlock_error";
|
||||
case e_interrupted_error: return "interrupted_error";
|
||||
case e_size_exceeded_error: return "size_exceeded";
|
||||
case e_append_fragment_error: return "append_fragment_error";
|
||||
}
|
||||
return "unknown";
|
||||
@ -393,7 +395,7 @@ namespace wsrep
|
||||
* in the DBMS cluster, so it may be relatively heavy operation.
|
||||
* Method wait_for_gtid() should be used whenever possible.
|
||||
*/
|
||||
int causal_read() const;
|
||||
enum wsrep::provider::status causal_read() const;
|
||||
|
||||
/**
|
||||
* Wait until all the write sets up to given GTID have been
|
||||
@ -401,7 +403,7 @@ namespace wsrep
|
||||
*
|
||||
* @return Zero on success, non-zero on failure.
|
||||
*/
|
||||
int wait_for_gtid(const wsrep::gtid&) const;
|
||||
enum wsrep::provider::status wait_for_gtid(const wsrep::gtid&) const;
|
||||
|
||||
//
|
||||
//
|
||||
@ -413,7 +415,7 @@ namespace wsrep
|
||||
/**
|
||||
* Enter total order isolation critical section.
|
||||
*/
|
||||
int enter_toi();
|
||||
enum wsrep::provider::status enter_toi();
|
||||
|
||||
/**
|
||||
* Leave total order isolation critical section.
|
||||
@ -423,7 +425,7 @@ namespace wsrep
|
||||
/**
|
||||
* Begin non-blocking operation.
|
||||
*/
|
||||
int begin_nbo();
|
||||
int begin_nbo(const wsrep::key_array&);
|
||||
|
||||
/**
|
||||
* End non-blocking operation
|
||||
|
@ -57,6 +57,9 @@ namespace wsrep
|
||||
wsrep::const_buffer key_parts_[3];
|
||||
size_t key_parts_len_;
|
||||
};
|
||||
|
||||
typedef std::vector<wsrep::key> key_array;
|
||||
|
||||
}
|
||||
|
||||
#endif // WSREP_KEY_HPP
|
||||
|
@ -196,7 +196,7 @@ namespace wsrep
|
||||
/**
|
||||
* Provider capabilities.
|
||||
*/
|
||||
struct capabilities
|
||||
struct capability
|
||||
{
|
||||
static const int multi_master = (1 << 0);
|
||||
static const int certification = (1 << 1);
|
||||
@ -228,6 +228,12 @@ namespace wsrep
|
||||
bool bootstrap) = 0;
|
||||
virtual int disconnect() = 0;
|
||||
|
||||
virtual int capabilities() const = 0;
|
||||
virtual int desync() = 0;
|
||||
virtual int resync() = 0;
|
||||
|
||||
virtual int pause() = 0;
|
||||
virtual int resume() = 0;
|
||||
|
||||
// Applier interface
|
||||
virtual enum status run_applier(void* applier_ctx) = 0;
|
||||
@ -235,7 +241,8 @@ namespace wsrep
|
||||
// TODO: Rename to assing_read_view()
|
||||
virtual int start_transaction(wsrep::ws_handle&) = 0;
|
||||
virtual int append_key(wsrep::ws_handle&, const wsrep::key&) = 0;
|
||||
virtual int append_data(wsrep::ws_handle&, const wsrep::const_buffer&) = 0;
|
||||
virtual enum status append_data(
|
||||
wsrep::ws_handle&, const wsrep::const_buffer&) = 0;
|
||||
virtual enum status
|
||||
certify(wsrep::client_id, wsrep::ws_handle&,
|
||||
int,
|
||||
@ -274,6 +281,10 @@ namespace wsrep
|
||||
virtual int sst_received(const wsrep::gtid&, int) = 0;
|
||||
|
||||
virtual std::vector<status_variable> status() const = 0;
|
||||
virtual void reset_status() = 0;
|
||||
|
||||
virtual std::string options() const = 0;
|
||||
virtual void options(const std::string&) = 0;
|
||||
|
||||
/**
|
||||
* Return pointer to native provider handle.
|
||||
|
@ -316,6 +316,7 @@ namespace wsrep
|
||||
const wsrep::ws_meta& ws_meta,
|
||||
const wsrep::const_buffer& data);
|
||||
|
||||
enum state state() const { return state_; }
|
||||
/**
|
||||
* Set server wide wsrep debug logging level.
|
||||
*
|
||||
|
@ -155,7 +155,7 @@ namespace wsrep
|
||||
wsrep::streaming_context streaming_context_;
|
||||
};
|
||||
|
||||
static inline std::string to_string(enum wsrep::transaction::state state)
|
||||
static inline const char* to_c_string(enum wsrep::transaction::state state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
@ -174,6 +174,10 @@ namespace wsrep
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
static inline std::string to_string(enum wsrep::transaction::state state)
|
||||
{
|
||||
return to_c_string(state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ wsrep::client_state::after_statement()
|
||||
(void)transaction_.after_statement();
|
||||
if (current_error() == wsrep::e_deadlock_error)
|
||||
{
|
||||
if (client_service_.is_autocommit())
|
||||
if (mode_ == m_replicating && client_service_.is_autocommit())
|
||||
{
|
||||
debug_log_state("after_statement: may_retry");
|
||||
return asr_may_retry;
|
||||
|
@ -506,6 +506,30 @@ int wsrep::wsrep_provider_v26::disconnect()
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wsrep::wsrep_provider_v26::capabilities() const
|
||||
{
|
||||
return wsrep_->capabilities(wsrep_);
|
||||
}
|
||||
int wsrep::wsrep_provider_v26::desync()
|
||||
{
|
||||
return (wsrep_->desync(wsrep_) != WSREP_OK);
|
||||
}
|
||||
|
||||
int wsrep::wsrep_provider_v26::resync()
|
||||
{
|
||||
return (wsrep_->resync(wsrep_) != WSREP_OK);
|
||||
}
|
||||
|
||||
int wsrep::wsrep_provider_v26::pause()
|
||||
{
|
||||
return (wsrep_->pause(wsrep_) != WSREP_OK);
|
||||
}
|
||||
|
||||
int wsrep::wsrep_provider_v26::resume()
|
||||
{
|
||||
return (wsrep_->resume(wsrep_) != WSREP_OK);
|
||||
}
|
||||
|
||||
enum wsrep::provider::status
|
||||
wsrep::wsrep_provider_v26::run_applier(void *applier_ctx)
|
||||
{
|
||||
@ -534,14 +558,15 @@ int wsrep::wsrep_provider_v26::append_key(wsrep::ws_handle& ws_handle,
|
||||
!= WSREP_OK);
|
||||
}
|
||||
|
||||
int wsrep::wsrep_provider_v26::append_data(wsrep::ws_handle& ws_handle,
|
||||
enum wsrep::provider::status
|
||||
wsrep::wsrep_provider_v26::append_data(wsrep::ws_handle& ws_handle,
|
||||
const wsrep::const_buffer& data)
|
||||
{
|
||||
const wsrep_buf_t wsrep_buf = {data.data(), data.size()};
|
||||
mutable_ws_handle mwsh(ws_handle);
|
||||
return (wsrep_->append_data(wsrep_, mwsh.native(), &wsrep_buf,
|
||||
1, WSREP_DATA_ORDERED, true)
|
||||
!= WSREP_OK);
|
||||
return map_return_value(
|
||||
wsrep_->append_data(wsrep_, mwsh.native(), &wsrep_buf,
|
||||
1, WSREP_DATA_ORDERED, true));
|
||||
}
|
||||
|
||||
enum wsrep::provider::status
|
||||
@ -674,6 +699,35 @@ wsrep::wsrep_provider_v26::status() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wsrep::wsrep_provider_v26::reset_status()
|
||||
{
|
||||
wsrep_->stats_reset(wsrep_);
|
||||
}
|
||||
|
||||
std::string wsrep::wsrep_provider_v26::options() const
|
||||
{
|
||||
std::string ret;
|
||||
char* opts;
|
||||
if ((opts = wsrep_->options_get(wsrep_)))
|
||||
{
|
||||
ret = opts;
|
||||
free(opts);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw wsrep::runtime_error("Failed to get provider options");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wsrep::wsrep_provider_v26::options(const std::string& opts)
|
||||
{
|
||||
if (wsrep_->options_set(wsrep_, opts.c_str()) != WSREP_OK)
|
||||
{
|
||||
throw wsrep::runtime_error("Failed to set provider options");
|
||||
}
|
||||
}
|
||||
|
||||
void* wsrep::wsrep_provider_v26::native() const
|
||||
{
|
||||
return wsrep_;
|
||||
|
@ -21,11 +21,18 @@ namespace wsrep
|
||||
int connect(const std::string&, const std::string&, const std::string&,
|
||||
bool);
|
||||
int disconnect();
|
||||
int capabilities() const;
|
||||
|
||||
int desync();
|
||||
int resync();
|
||||
int pause();
|
||||
int resume();
|
||||
|
||||
enum wsrep::provider::status run_applier(void*);
|
||||
int start_transaction(wsrep::ws_handle&) { return 0; }
|
||||
int append_key(wsrep::ws_handle&, const wsrep::key&);
|
||||
int append_data(wsrep::ws_handle&, const wsrep::const_buffer&);
|
||||
enum wsrep::provider::status
|
||||
append_data(wsrep::ws_handle&, const wsrep::const_buffer&);
|
||||
enum wsrep::provider::status
|
||||
certify(wsrep::client_id, wsrep::ws_handle&,
|
||||
int,
|
||||
@ -46,6 +53,9 @@ namespace wsrep
|
||||
int sst_received(const wsrep::gtid& gtid, int);
|
||||
|
||||
std::vector<status_variable> status() const;
|
||||
void reset_status();
|
||||
std::string options() const;
|
||||
void options(const std::string&);
|
||||
void* native() const;
|
||||
private:
|
||||
wsrep_provider_v26(const wsrep_provider_v26&);
|
||||
|
@ -43,6 +43,11 @@ namespace wsrep
|
||||
bool)
|
||||
{ return 0; }
|
||||
int disconnect() { return 0; }
|
||||
int capabilities() const { return 0; }
|
||||
int desync() { return 0; }
|
||||
int resync() { return 0; }
|
||||
int pause() { return 0; }
|
||||
int resume() { return 0; }
|
||||
enum wsrep::provider::status run_applier(void*)
|
||||
{
|
||||
return wsrep::provider::success;
|
||||
@ -121,8 +126,9 @@ namespace wsrep
|
||||
|
||||
int append_key(wsrep::ws_handle&, const wsrep::key&)
|
||||
{ return 0; }
|
||||
int append_data(wsrep::ws_handle&, const wsrep::const_buffer&)
|
||||
{ return 0; }
|
||||
enum wsrep::provider::status
|
||||
append_data(wsrep::ws_handle&, const wsrep::const_buffer&)
|
||||
{ return wsrep::provider::success; }
|
||||
int rollback(const wsrep::transaction_id)
|
||||
{
|
||||
++fragments_;
|
||||
@ -199,6 +205,9 @@ namespace wsrep
|
||||
{
|
||||
return std::vector<status_variable>();
|
||||
}
|
||||
void reset_status() { }
|
||||
std::string options() const { return ""; }
|
||||
void options(const std::string&) { }
|
||||
void* native() const { return 0; }
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user