summaryrefslogtreecommitdiff
path: root/extra/mariabackup/wsrep.cc
diff options
context:
space:
mode:
authorTeemu Ollakka <teemu.ollakka@galeracluster.com>2018-03-12 12:39:30 +0200
committerTeemu Ollakka <teemu.ollakka@galeracluster.com>2018-03-12 14:51:49 +0200
commitb125ae0a842744dbf40fb38cc3df0e2ba3721dd3 (patch)
tree0650d1f807a01ca2f229ab86b0854a6053b53b40 /extra/mariabackup/wsrep.cc
parentdd74b94823711ecb4529b8368c2f6161f39b9fa0 (diff)
downloadmariadb-git-b125ae0a842744dbf40fb38cc3df0e2ba3721dd3.tar.gz
MDEV-15505 New wsrep XID format for backwards compatibility
A new wsrep XID format was added to keep the XID implementation backwards compatible. Original version always reads XID seqno part in host byte order, the new version in little endian byte order. Wsrep XID will always be written in the new format. Included wsrep_api.h from service_wsrep.h for wsrep type definitions. Removed redundant wsrep XID code from mariabackup and included service_wsrep.h in order to use
Diffstat (limited to 'extra/mariabackup/wsrep.cc')
-rw-r--r--extra/mariabackup/wsrep.cc107
1 files changed, 4 insertions, 103 deletions
diff --git a/extra/mariabackup/wsrep.cc b/extra/mariabackup/wsrep.cc
index 33ba1c14fbf..dd3d5cb60d2 100644
--- a/extra/mariabackup/wsrep.cc
+++ b/extra/mariabackup/wsrep.cc
@@ -44,115 +44,14 @@ permission notice:
#include <my_base.h>
#include <handler.h>
#include <trx0rseg.h>
+#include <mysql/service_wsrep.h>
#include "common.h"
#ifdef WITH_WSREP
-#define WSREP_XID_PREFIX "WSREPXid"
-#define WSREP_XID_PREFIX_LEN MYSQL_XID_PREFIX_LEN
-#define WSREP_XID_UUID_OFFSET 8
-#define WSREP_XID_SEQNO_OFFSET (WSREP_XID_UUID_OFFSET + sizeof(wsrep_uuid_t))
-#define WSREP_XID_GTRID_LEN (WSREP_XID_SEQNO_OFFSET + sizeof(wsrep_seqno_t))
-
-/*! undefined seqno */
-#define WSREP_SEQNO_UNDEFINED (-1)
/*! Name of file where Galera info is stored on recovery */
#define XB_GALERA_INFO_FILENAME "xtrabackup_galera_info"
-/* Galera UUID type - for all unique IDs */
-typedef struct wsrep_uuid {
- unsigned char data[16];
-} wsrep_uuid_t;
-
-/* sequence number of a writeset, etc. */
-typedef long long wsrep_seqno_t;
-
-/* Undefined UUID */
-static const wsrep_uuid_t WSREP_UUID_UNDEFINED = {{0,}};
-
-/***********************************************************************//**
-Check if a given WSREP XID is valid.
-
-@return true if valid.
-*/
-static
-bool
-wsrep_is_wsrep_xid(
-/*===============*/
- const void* xid_ptr)
-{
- const XID* xid = reinterpret_cast<const XID*>(xid_ptr);
-
- return((xid->formatID == 1 &&
- xid->gtrid_length == WSREP_XID_GTRID_LEN &&
- xid->bqual_length == 0 &&
- !memcmp(xid->data, WSREP_XID_PREFIX, WSREP_XID_PREFIX_LEN)));
-}
-
-/***********************************************************************//**
-Retrieve binary WSREP UUID from XID.
-
-@return binary WSREP UUID represenataion, if UUID is valid, or
- WSREP_UUID_UNDEFINED otherwise.
-*/
-static
-const wsrep_uuid_t*
-wsrep_xid_uuid(
-/*===========*/
- const XID* xid)
-{
- if (wsrep_is_wsrep_xid(xid)) {
- return(reinterpret_cast<const wsrep_uuid_t*>
- (xid->data + WSREP_XID_UUID_OFFSET));
- } else {
- return(&WSREP_UUID_UNDEFINED);
- }
-}
-
-/***********************************************************************//**
-Retrieve WSREP seqno from XID.
-
-@return WSREP seqno, if it is valid, or WSREP_SEQNO_UNDEFINED otherwise.
-*/
-wsrep_seqno_t wsrep_xid_seqno(
-/*==========================*/
- const XID* xid)
-{
- if (wsrep_is_wsrep_xid(xid)) {
- return sint8korr(xid->data + WSREP_XID_SEQNO_OFFSET);
- } else {
- return(WSREP_SEQNO_UNDEFINED);
- }
-}
-
-/***********************************************************************//**
-Write UUID to string.
-
-@return length of UUID string representation or -EMSGSIZE if string is too
-short.
-*/
-static
-int
-wsrep_uuid_print(
-/*=============*/
- const wsrep_uuid_t* uuid,
- char* str,
- size_t str_len)
-{
- if (str_len > 36) {
- const unsigned char* u = uuid->data;
- return snprintf(str, str_len,
- "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
- "%02x%02x-%02x%02x%02x%02x%02x%02x",
- u[ 0], u[ 1], u[ 2], u[ 3], u[ 4], u[ 5], u[ 6],
- u[ 7], u[ 8], u[ 9], u[10], u[11], u[12], u[13],
- u[14], u[15]);
- }
- else {
- return -EMSGSIZE;
- }
-}
-
/***********************************************************************
Store Galera checkpoint info in the 'xtrabackup_galera_info' file, if that
information is present in the trx system header. Otherwise, do nothing. */
@@ -182,7 +81,9 @@ xb_write_galera_info(bool incremental_prepare)
return;
}
- if (wsrep_uuid_print(wsrep_xid_uuid(&xid), uuid_str,
+ wsrep_uuid_t uuid;
+ memcpy(uuid.data, wsrep_xid_uuid(&xid), sizeof(uuid.data));
+ if (wsrep_uuid_print(&uuid, uuid_str,
sizeof(uuid_str)) < 0) {
return;
}