summaryrefslogtreecommitdiff
path: root/sql/wsrep_xid.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 /sql/wsrep_xid.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 'sql/wsrep_xid.cc')
-rw-r--r--sql/wsrep_xid.cc30
1 files changed, 22 insertions, 8 deletions
diff --git a/sql/wsrep_xid.cc b/sql/wsrep_xid.cc
index 6e3c1cf6386..04d48819397 100644
--- a/sql/wsrep_xid.cc
+++ b/sql/wsrep_xid.cc
@@ -25,8 +25,11 @@
* WSREPXid
*/
-#define WSREP_XID_PREFIX "WSREPXid"
-#define WSREP_XID_PREFIX_LEN MYSQL_XID_PREFIX_LEN
+#define WSREP_XID_PREFIX "WSREPXi"
+#define WSREP_XID_PREFIX_LEN 7
+#define WSREP_XID_VERSION_OFFSET WSREP_XID_PREFIX_LEN
+#define WSREP_XID_VERSION_1 'd'
+#define WSREP_XID_VERSION_2 'e'
#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))
@@ -38,6 +41,7 @@ void wsrep_xid_init(XID* xid, const wsrep_uuid_t& uuid, wsrep_seqno_t seqno)
xid->bqual_length= 0;
memset(xid->data, 0, sizeof(xid->data));
memcpy(xid->data, WSREP_XID_PREFIX, WSREP_XID_PREFIX_LEN);
+ xid->data[WSREP_XID_VERSION_OFFSET] = WSREP_XID_VERSION_2;
memcpy(xid->data + WSREP_XID_UUID_OFFSET, &uuid, sizeof(wsrep_uuid_t));
int8store(xid->data + WSREP_XID_SEQNO_OFFSET,seqno);
}
@@ -47,7 +51,9 @@ int wsrep_is_wsrep_xid(const XID* xid)
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));
+ !memcmp(xid->data, WSREP_XID_PREFIX, WSREP_XID_PREFIX_LEN) &&
+ (xid->data[WSREP_XID_VERSION_OFFSET] == WSREP_XID_VERSION_1 ||
+ xid->data[WSREP_XID_VERSION_OFFSET] == WSREP_XID_VERSION_2));
}
const wsrep_uuid_t* wsrep_xid_uuid(const XID& xid)
@@ -67,14 +73,22 @@ const unsigned char* wsrep_xid_uuid(const xid_t* xid)
wsrep_seqno_t wsrep_xid_seqno(const XID& xid)
{
+ wsrep_seqno_t ret= WSREP_SEQNO_UNDEFINED;
if (wsrep_is_wsrep_xid(&xid))
{
- return sint8korr(xid.data + WSREP_XID_SEQNO_OFFSET);
- }
- else
- {
- return WSREP_SEQNO_UNDEFINED;
+ switch (xid.data[WSREP_XID_VERSION_OFFSET])
+ {
+ case WSREP_XID_VERSION_1:
+ memcpy(&ret, xid.data + WSREP_XID_SEQNO_OFFSET, sizeof ret);
+ break;
+ case WSREP_XID_VERSION_2:
+ ret= sint8korr(xid.data + WSREP_XID_SEQNO_OFFSET);
+ break;
+ default:
+ break;
+ }
}
+ return ret;
}
wsrep_seqno_t wsrep_xid_seqno(const xid_t* xid)