mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-28 20:02:00 +03:00
Add type wsrep::xid
Create type `wsrep::xid`, and change all signatures that take `std::string xid` to take `wsrep::xid xid`.
This commit is contained in:
@ -42,7 +42,7 @@ namespace db
|
|||||||
const wsrep::ws_handle&,
|
const wsrep::ws_handle&,
|
||||||
const wsrep::ws_meta&,
|
const wsrep::ws_meta&,
|
||||||
const wsrep::const_buffer&,
|
const wsrep::const_buffer&,
|
||||||
const std::string&) override
|
const wsrep::xid&) override
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
int remove_fragments(const wsrep::ws_meta&) override
|
int remove_fragments(const wsrep::ws_meta&) override
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
@ -35,7 +35,7 @@ namespace db
|
|||||||
wsrep::transaction_id,
|
wsrep::transaction_id,
|
||||||
int,
|
int,
|
||||||
const wsrep::const_buffer&,
|
const wsrep::const_buffer&,
|
||||||
const std::string&) override
|
const wsrep::xid&) override
|
||||||
{ throw wsrep::not_implemented_error(); }
|
{ throw wsrep::not_implemented_error(); }
|
||||||
int update_fragment_meta(const wsrep::ws_meta&) override
|
int update_fragment_meta(const wsrep::ws_meta&) override
|
||||||
{ throw wsrep::not_implemented_error(); }
|
{ throw wsrep::not_implemented_error(); }
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
#include "lock.hpp"
|
#include "lock.hpp"
|
||||||
#include "buffer.hpp"
|
#include "buffer.hpp"
|
||||||
#include "thread.hpp"
|
#include "thread.hpp"
|
||||||
|
#include "xid.hpp"
|
||||||
|
|
||||||
namespace wsrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
@ -533,7 +534,7 @@ namespace wsrep
|
|||||||
*
|
*
|
||||||
* @param xid transaction id
|
* @param xid transaction id
|
||||||
*/
|
*/
|
||||||
void assign_xid(const std::string& xid)
|
void assign_xid(const wsrep::xid& xid)
|
||||||
{
|
{
|
||||||
transaction_.assign_xid(xid);
|
transaction_.assign_xid(xid);
|
||||||
}
|
}
|
||||||
@ -544,7 +545,7 @@ namespace wsrep
|
|||||||
* The purpose of this method is to restore transaction state
|
* The purpose of this method is to restore transaction state
|
||||||
* during recovery of a prepared XA transaction.
|
* during recovery of a prepared XA transaction.
|
||||||
*/
|
*/
|
||||||
int restore_xid(std::string& xid)
|
int restore_xid(const wsrep::xid& xid)
|
||||||
{
|
{
|
||||||
return transaction_.restore_to_prepared_state(xid);
|
return transaction_.restore_to_prepared_state(xid);
|
||||||
}
|
}
|
||||||
@ -562,7 +563,7 @@ namespace wsrep
|
|||||||
* @return Zero on success, non-zero on error. In case of error
|
* @return Zero on success, non-zero on error. In case of error
|
||||||
* the client_state's current_error is set
|
* the client_state's current_error is set
|
||||||
*/
|
*/
|
||||||
int commit_by_xid(const std::string& xid)
|
int commit_by_xid(const wsrep::xid& xid)
|
||||||
{
|
{
|
||||||
return transaction_.commit_or_rollback_by_xid(xid, true);
|
return transaction_.commit_or_rollback_by_xid(xid, true);
|
||||||
}
|
}
|
||||||
@ -580,7 +581,7 @@ namespace wsrep
|
|||||||
* @return Zero on success, non-zero on error. In case of error
|
* @return Zero on success, non-zero on error. In case of error
|
||||||
* the client_state's current_error is set
|
* the client_state's current_error is set
|
||||||
*/
|
*/
|
||||||
int rollback_by_xid(const std::string& xid)
|
int rollback_by_xid(const wsrep::xid& xid)
|
||||||
{
|
{
|
||||||
return transaction_.commit_or_rollback_by_xid(xid, false);
|
return transaction_.commit_or_rollback_by_xid(xid, false);
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#ifndef WSREP_HIGH_PRIORITY_SERVICE_HPP
|
#ifndef WSREP_HIGH_PRIORITY_SERVICE_HPP
|
||||||
#define WSREP_HIGH_PRIORITY_SERVICE_HPP
|
#define WSREP_HIGH_PRIORITY_SERVICE_HPP
|
||||||
|
|
||||||
|
#include "xid.hpp"
|
||||||
#include "server_state.hpp"
|
#include "server_state.hpp"
|
||||||
|
|
||||||
namespace wsrep
|
namespace wsrep
|
||||||
@ -97,7 +98,7 @@ namespace wsrep
|
|||||||
const wsrep::ws_handle& ws_handle,
|
const wsrep::ws_handle& ws_handle,
|
||||||
const wsrep::ws_meta& ws_meta,
|
const wsrep::ws_meta& ws_meta,
|
||||||
const wsrep::const_buffer& data,
|
const wsrep::const_buffer& data,
|
||||||
const std::string& xid) = 0;
|
const wsrep::xid& xid) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove fragments belonging to streaming transaction.
|
* Remove fragments belonging to streaming transaction.
|
||||||
|
@ -90,6 +90,7 @@
|
|||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
#include "provider.hpp"
|
#include "provider.hpp"
|
||||||
#include "compiler.hpp"
|
#include "compiler.hpp"
|
||||||
|
#include "xid.hpp"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -268,7 +269,7 @@ namespace wsrep
|
|||||||
* Find a streaming applier matching xid
|
* Find a streaming applier matching xid
|
||||||
*/
|
*/
|
||||||
wsrep::high_priority_service* find_streaming_applier(
|
wsrep::high_priority_service* find_streaming_applier(
|
||||||
const std::string& xid) const;
|
const wsrep::xid& xid) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load WSRep provider.
|
* Load WSRep provider.
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "transaction_id.hpp"
|
#include "transaction_id.hpp"
|
||||||
#include "id.hpp"
|
#include "id.hpp"
|
||||||
#include "buffer.hpp"
|
#include "buffer.hpp"
|
||||||
|
#include "xid.hpp"
|
||||||
|
|
||||||
namespace wsrep
|
namespace wsrep
|
||||||
{
|
{
|
||||||
@ -64,7 +65,7 @@ namespace wsrep
|
|||||||
wsrep::transaction_id client_id,
|
wsrep::transaction_id client_id,
|
||||||
int flags,
|
int flags,
|
||||||
const wsrep::const_buffer& data,
|
const wsrep::const_buffer& data,
|
||||||
const std::string& xid) = 0;
|
const wsrep::xid& xid) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update fragment meta data after certification process.
|
* Update fragment meta data after certification process.
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "sr_key_set.hpp"
|
#include "sr_key_set.hpp"
|
||||||
#include "buffer.hpp"
|
#include "buffer.hpp"
|
||||||
#include "client_service.hpp"
|
#include "client_service.hpp"
|
||||||
|
#include "xid.hpp"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -127,21 +128,21 @@ namespace wsrep
|
|||||||
return !xid_.empty();
|
return !xid_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void assign_xid(const std::string& xid)
|
void assign_xid(const wsrep::xid& xid)
|
||||||
{
|
{
|
||||||
assert(active());
|
assert(active());
|
||||||
assert(xid_.empty());
|
assert(xid_.empty());
|
||||||
xid_ = xid;
|
xid_ = xid;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string xid() const
|
const wsrep::xid xid() const
|
||||||
{
|
{
|
||||||
return xid_;
|
return xid_;
|
||||||
}
|
}
|
||||||
|
|
||||||
int restore_to_prepared_state(const std::string& xid);
|
int restore_to_prepared_state(const wsrep::xid& xid);
|
||||||
|
|
||||||
int commit_or_rollback_by_xid(const std::string& xid, bool commit);
|
int commit_or_rollback_by_xid(const wsrep::xid& xid, bool commit);
|
||||||
|
|
||||||
bool pa_unsafe() const { return pa_unsafe_; }
|
bool pa_unsafe() const { return pa_unsafe_; }
|
||||||
void pa_unsafe(bool pa_unsafe) { pa_unsafe_ = pa_unsafe; }
|
void pa_unsafe(bool pa_unsafe) { pa_unsafe_ = pa_unsafe; }
|
||||||
@ -273,7 +274,7 @@ namespace wsrep
|
|||||||
wsrep::streaming_context streaming_context_;
|
wsrep::streaming_context streaming_context_;
|
||||||
wsrep::sr_key_set sr_keys_;
|
wsrep::sr_key_set sr_keys_;
|
||||||
wsrep::mutable_buffer apply_error_buf_;
|
wsrep::mutable_buffer apply_error_buf_;
|
||||||
std::string xid_;
|
wsrep::xid xid_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline const char* to_c_string(enum wsrep::transaction::state state)
|
static inline const char* to_c_string(enum wsrep::transaction::state state)
|
||||||
|
47
include/wsrep/xid.hpp
Normal file
47
include/wsrep/xid.hpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Codership Oy <info@codership.com>
|
||||||
|
*
|
||||||
|
* This file is part of wsrep-lib.
|
||||||
|
*
|
||||||
|
* Wsrep-lib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Wsrep-lib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with wsrep-lib. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef WSREP_XID_HPP
|
||||||
|
#define WSREP_XID_HPP
|
||||||
|
|
||||||
|
#include <iosfwd>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace wsrep
|
||||||
|
{
|
||||||
|
class xid
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
xid() : xid_() { }
|
||||||
|
xid(const std::string& str) : xid_(str) { }
|
||||||
|
xid(const char* s) : xid_(s) { }
|
||||||
|
bool empty() const { return xid_.empty(); }
|
||||||
|
void clear() { xid_.clear(); }
|
||||||
|
bool operator==(const xid& other) const { return xid_ == other.xid_; }
|
||||||
|
friend std::string to_string(const wsrep::xid& xid);
|
||||||
|
friend std::ostream& operator<<(std::ostream& os, const wsrep::xid& xid);
|
||||||
|
private:
|
||||||
|
std::string xid_;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string to_string(const wsrep::xid& xid);
|
||||||
|
std::ostream& operator<<(std::ostream& os, const wsrep::xid& xid);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // WSREP_XID_HPP
|
@ -7,6 +7,7 @@ add_library(wsrep-lib
|
|||||||
exception.cpp
|
exception.cpp
|
||||||
gtid.cpp
|
gtid.cpp
|
||||||
id.cpp
|
id.cpp
|
||||||
|
xid.cpp
|
||||||
key.cpp
|
key.cpp
|
||||||
logger.cpp
|
logger.cpp
|
||||||
provider.cpp
|
provider.cpp
|
||||||
|
@ -130,7 +130,7 @@ static int apply_fragment(wsrep::server_state& server_state,
|
|||||||
if (!apply_err)
|
if (!apply_err)
|
||||||
{
|
{
|
||||||
high_priority_service.debug_crash("crash_apply_cb_before_append_frag");
|
high_priority_service.debug_crash("crash_apply_cb_before_append_frag");
|
||||||
const std::string xid(streaming_applier->transaction().xid());
|
const wsrep::xid xid(streaming_applier->transaction().xid());
|
||||||
ret = high_priority_service.append_fragment_and_commit(
|
ret = high_priority_service.append_fragment_and_commit(
|
||||||
ws_handle, ws_meta, data, xid);
|
ws_handle, ws_meta, data, xid);
|
||||||
high_priority_service.debug_crash("crash_apply_cb_after_append_frag");
|
high_priority_service.debug_crash("crash_apply_cb_after_append_frag");
|
||||||
@ -1258,7 +1258,7 @@ wsrep::high_priority_service* wsrep::server_state::find_streaming_applier(
|
|||||||
}
|
}
|
||||||
|
|
||||||
wsrep::high_priority_service* wsrep::server_state::find_streaming_applier(
|
wsrep::high_priority_service* wsrep::server_state::find_streaming_applier(
|
||||||
const std::string& xid) const
|
const wsrep::xid& xid) const
|
||||||
{
|
{
|
||||||
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
streaming_appliers_map::const_iterator i(streaming_appliers_.begin());
|
streaming_appliers_map::const_iterator i(streaming_appliers_.begin());
|
||||||
|
@ -1040,7 +1040,7 @@ void wsrep::transaction::after_replay(const wsrep::transaction& other)
|
|||||||
clear_fragments();
|
clear_fragments();
|
||||||
}
|
}
|
||||||
|
|
||||||
int wsrep::transaction::restore_to_prepared_state(const std::string& xid)
|
int wsrep::transaction::restore_to_prepared_state(const wsrep::xid& xid)
|
||||||
{
|
{
|
||||||
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex_);
|
||||||
assert(active());
|
assert(active());
|
||||||
@ -1053,7 +1053,7 @@ int wsrep::transaction::restore_to_prepared_state(const std::string& xid)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wsrep::transaction::commit_or_rollback_by_xid(const std::string& xid,
|
int wsrep::transaction::commit_or_rollback_by_xid(const wsrep::xid& xid,
|
||||||
bool commit)
|
bool commit)
|
||||||
{
|
{
|
||||||
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(client_state_.mutex_);
|
||||||
|
31
src/xid.cpp
Normal file
31
src/xid.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Codership Oy <info@codership.com>
|
||||||
|
*
|
||||||
|
* This file is part of wsrep-lib.
|
||||||
|
*
|
||||||
|
* Wsrep-lib is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Wsrep-lib is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with wsrep-lib. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "wsrep/xid.hpp"
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
std::string wsrep::to_string(const wsrep::xid& xid)
|
||||||
|
{
|
||||||
|
return xid.xid_;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& wsrep::operator<<(std::ostream& os, const wsrep::xid& xid)
|
||||||
|
{
|
||||||
|
return os << xid.xid_;
|
||||||
|
}
|
@ -55,7 +55,7 @@ namespace wsrep
|
|||||||
const wsrep::ws_handle&,
|
const wsrep::ws_handle&,
|
||||||
const wsrep::ws_meta&,
|
const wsrep::ws_meta&,
|
||||||
const wsrep::const_buffer&,
|
const wsrep::const_buffer&,
|
||||||
const std::string&) WSREP_OVERRIDE
|
const wsrep::xid&) WSREP_OVERRIDE
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
int remove_fragments(const wsrep::ws_meta&) WSREP_OVERRIDE
|
int remove_fragments(const wsrep::ws_meta&) WSREP_OVERRIDE
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
@ -40,7 +40,7 @@ class mock_server_state;
|
|||||||
wsrep::transaction_id,
|
wsrep::transaction_id,
|
||||||
int,
|
int,
|
||||||
const wsrep::const_buffer&,
|
const wsrep::const_buffer&,
|
||||||
const std::string&) WSREP_OVERRIDE
|
const wsrep::xid&) WSREP_OVERRIDE
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
int update_fragment_meta(const wsrep::ws_meta&) WSREP_OVERRIDE
|
int update_fragment_meta(const wsrep::ws_meta&) WSREP_OVERRIDE
|
||||||
|
Submodule wsrep-API/v26 updated: 35b9ecedd8...12a50c43b1
Reference in New Issue
Block a user