diff options
author | Teemu Ollakka <teemu.ollakka@galeracluster.com> | 2018-03-07 18:40:15 +0200 |
---|---|---|
committer | Teemu Ollakka <teemu.ollakka@galeracluster.com> | 2018-03-12 14:46:20 +0200 |
commit | dd74b94823711ecb4529b8368c2f6161f39b9fa0 (patch) | |
tree | e9daf35be635413542f3f91179031d8cb228798d /sql/wsrep_xid.cc | |
parent | 09c5c335e3e8447e7d07c987293042175b51b495 (diff) | |
download | mariadb-git-dd74b94823711ecb4529b8368c2f6161f39b9fa0.tar.gz |
MDEV-15505 Fix wsrep XID seqno byte order
The problem is that the seqno part of wsrep XID is always
stored in host byte order. This may cause issues when a physical
backup is restored on a host with different architecture, the
seqno part with XID may have incorrect value.
In order to fix this, wsrep XID seqno is always written into
XID data buffer in little endian byte order using int8store()
and read from data buffer using sint8korr(). For backwards
compatibility the seqno is read from TRX_SYS page in host
byte order during upgrade.
This patch implements byte ordering in wsrep_xid_init(),
wsrep_xid_seqno(), and exposes functions to read wsrep
XID uuid and seqno in wsrep_service_st. Backwards compatibility
for upgrade is provided in trx_rseg_init_wsrep_xid().
Diffstat (limited to 'sql/wsrep_xid.cc')
-rw-r--r-- | sql/wsrep_xid.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sql/wsrep_xid.cc b/sql/wsrep_xid.cc index 5af39bfc230..6e3c1cf6386 100644 --- a/sql/wsrep_xid.cc +++ b/sql/wsrep_xid.cc @@ -39,7 +39,7 @@ void wsrep_xid_init(XID* xid, const wsrep_uuid_t& uuid, wsrep_seqno_t seqno) memset(xid->data, 0, sizeof(xid->data)); memcpy(xid->data, WSREP_XID_PREFIX, WSREP_XID_PREFIX_LEN); memcpy(xid->data + WSREP_XID_UUID_OFFSET, &uuid, sizeof(wsrep_uuid_t)); - memcpy(xid->data + WSREP_XID_SEQNO_OFFSET, &seqno, sizeof(wsrep_seqno_t)); + int8store(xid->data + WSREP_XID_SEQNO_OFFSET,seqno); } int wsrep_is_wsrep_xid(const XID* xid) @@ -59,13 +59,17 @@ const wsrep_uuid_t* wsrep_xid_uuid(const XID& xid) return &WSREP_UUID_UNDEFINED; } +const unsigned char* wsrep_xid_uuid(const xid_t* xid) +{ + DBUG_ASSERT(xid); + return wsrep_xid_uuid(*xid)->data; +} + wsrep_seqno_t wsrep_xid_seqno(const XID& xid) { if (wsrep_is_wsrep_xid(&xid)) { - wsrep_seqno_t seqno; - memcpy(&seqno, xid.data + WSREP_XID_SEQNO_OFFSET, sizeof(wsrep_seqno_t)); - return seqno; + return sint8korr(xid.data + WSREP_XID_SEQNO_OFFSET); } else { @@ -73,6 +77,12 @@ wsrep_seqno_t wsrep_xid_seqno(const XID& xid) } } +wsrep_seqno_t wsrep_xid_seqno(const xid_t* xid) +{ + DBUG_ASSERT(xid); + return wsrep_xid_seqno(*xid); +} + static my_bool set_SE_checkpoint(THD* unused, plugin_ref plugin, void* arg) { XID* xid= static_cast<XID*>(arg); |