Skip to content

Commit

Permalink
MDEV-15505 Fixes to compilation without -DWITH_WSREP:BOOL=ON
Browse files Browse the repository at this point in the history
Removed including wsrep_api.h from service_wsrep.h. This caused
various kinds of collisions with definitions when wsrep is
not supposed to be built in. Defined functions wsrep_xid_seqno()
and wsrep_xid_uuid() in wsrep_dummy.cc. Replaced wsrep_seqno_t
with long long where wsrep_api.h is not included.

Removed wsrep_xid_seqno() macro from wsrep_mysqld.h and made
wsrep code using wsrep_xid_seqno() in handler.cc to be compiled
in only if WITH_WSREP is ON.

Included wsrep_api.h for mariabackup if WITH_WSREP is ON.
  • Loading branch information
temeo committed Mar 21, 2018
1 parent b125ae0 commit 33aad1d
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 14 deletions.
1 change: 0 additions & 1 deletion cmake/wsrep.cmake
Expand Up @@ -40,5 +40,4 @@ SET(WSREP_PROC_INFO ${WITH_WSREP})

IF(WITH_WSREP)
SET(WSREP_PATCH_VERSION "wsrep_${WSREP_VERSION}")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/wsrep)
ENDIF()
4 changes: 4 additions & 0 deletions extra/mariabackup/CMakeLists.txt
Expand Up @@ -40,6 +40,10 @@ IF(NOT HAVE_SYSTEM_REGEX)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/pcre)
ENDIF()

IF(WITH_WSREP)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/wsrep)
ENDIF()

ADD_DEFINITIONS(-UMYSQL_SERVER)
########################################################################
# xtrabackup binary
Expand Down
4 changes: 3 additions & 1 deletion extra/mariabackup/wsrep.cc
Expand Up @@ -49,6 +49,8 @@ permission notice:
#include "common.h"
#ifdef WITH_WSREP

#include <wsrep_api.h>

/*! Name of file where Galera info is stored on recovery */
#define XB_GALERA_INFO_FILENAME "xtrabackup_galera_info"

Expand All @@ -62,7 +64,7 @@ xb_write_galera_info(bool incremental_prepare)
FILE* fp;
XID xid;
char uuid_str[40];
wsrep_seqno_t seqno;
long long seqno;
MY_STAT statinfo;

/* Do not overwrite existing an existing file to be compatible with
Expand Down
8 changes: 4 additions & 4 deletions include/mysql/service_wsrep.h
Expand Up @@ -22,8 +22,6 @@
For engines that want to support galera.
*/

#include <wsrep_api.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -69,7 +67,9 @@ enum wsrep_trx_status {
};

struct xid_t;
struct wsrep;
struct wsrep_ws_handle;
struct wsrep_buf;

extern struct wsrep_service_st {
struct wsrep * (*get_wsrep_func)();
Expand All @@ -84,7 +84,7 @@ extern struct wsrep_service_st {
void (*wsrep_aborting_thd_enqueue_func)(THD *thd);
bool (*wsrep_consistency_check_func)(THD *thd);
int (*wsrep_is_wsrep_xid_func)(const struct xid_t *xid);
wsrep_seqno_t (*wsrep_xid_seqno_func)(const struct xid_t *xid);
long long (*wsrep_xid_seqno_func)(const struct xid_t *xid);
const unsigned char* (*wsrep_xid_uuid_func)(const struct xid_t *xid);
void (*wsrep_lock_rollback_func)();
int (*wsrep_on_func)(MYSQL_THD);
Expand Down Expand Up @@ -186,7 +186,7 @@ enum wsrep_exec_mode wsrep_thd_exec_mode(THD *thd);
enum wsrep_query_state wsrep_thd_query_state(THD *thd);
enum wsrep_trx_status wsrep_run_wsrep_commit(THD *thd, bool all);
int wsrep_is_wsrep_xid(const struct xid_t* xid);
wsrep_seqno_t wsrep_xid_seqno(const struct xid_t* xid);
long long wsrep_xid_seqno(const struct xid_t* xid);
const unsigned char* wsrep_xid_uuid(const struct xid_t* xid);
int wsrep_on(MYSQL_THD thd);
int wsrep_thd_retry_counter(THD *thd);
Expand Down
9 changes: 6 additions & 3 deletions sql/handler.cc
Expand Up @@ -1484,11 +1484,13 @@ int ha_commit_trans(THD *thd, bool all)
DEBUG_SYNC(thd, "ha_commit_trans_after_prepare");
DBUG_EXECUTE_IF("crash_commit_after_prepare", DBUG_SUICIDE(););

#ifdef WITH_WSREP
if (!error && WSREP_ON && wsrep_is_wsrep_xid(&thd->transaction.xid_state.xid))
{
// xid was rewritten by wsrep
xid= wsrep_xid_seqno(thd->transaction.xid_state.xid);
}
#endif /* WITH_WSREP */

if (!is_real_trans)
{
Expand Down Expand Up @@ -1914,9 +1916,10 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin,
got, hton_name(hton)->str);
for (int i=0; i < got; i ++)
{
my_xid x= WSREP_ON && wsrep_is_wsrep_xid(&info->list[i]) ?
wsrep_xid_seqno(info->list[i]) :
info->list[i].get_my_xid();
my_xid x= IF_WSREP(WSREP_ON && wsrep_is_wsrep_xid(&info->list[i]) ?
wsrep_xid_seqno(info->list[i]) :
info->list[i].get_my_xid(),
info->list[i].get_my_xid());
if (!x) // not "mine" - that is generated by external TM
{
#ifndef DBUG_OFF
Expand Down
9 changes: 9 additions & 0 deletions sql/wsrep_dummy.cc
Expand Up @@ -29,6 +29,15 @@ enum wsrep_conflict_state wsrep_thd_conflict_state(THD *, my_bool)
int wsrep_is_wsrep_xid(const XID*)
{ return 0; }

long long wsrep_xid_seqno(const XID* x)
{ return -1; }

const unsigned char* wsrep_xid_uuid(const XID*)
{
static const unsigned char uuid[16] = {0};
return uuid;
}

bool wsrep_prepare_key(const uchar*, size_t, const uchar*, size_t, struct wsrep_buf*, size_t*)
{ return 0; }

Expand Down
1 change: 0 additions & 1 deletion sql/wsrep_mysqld.h
Expand Up @@ -328,7 +328,6 @@ bool wsrep_node_is_synced();
#define WSREP_FORMAT(my_format) ((ulong)my_format)
#define WSREP_PROVIDER_EXISTS (0)
#define wsrep_emulate_bin_log (0)
#define wsrep_xid_seqno(X) (0)
#define wsrep_to_isolation (0)
#define wsrep_init() (1)
#define wsrep_prepend_PATH(X)
Expand Down
2 changes: 1 addition & 1 deletion sql/wsrep_xid.cc
Expand Up @@ -91,7 +91,7 @@ wsrep_seqno_t wsrep_xid_seqno(const XID& xid)
return ret;
}

wsrep_seqno_t wsrep_xid_seqno(const xid_t* xid)
long long wsrep_xid_seqno(const xid_t* xid)
{
DBUG_ASSERT(xid);
return wsrep_xid_seqno(*xid);
Expand Down
6 changes: 3 additions & 3 deletions storage/innobase/trx/trx0rseg.cc
Expand Up @@ -39,7 +39,7 @@ Created 3/26/1996 Heikki Tuuri

#ifdef UNIV_DEBUG
/** The latest known WSREP XID sequence number */
static wsrep_seqno_t wsrep_seqno = -1;
static long long wsrep_seqno = -1;
#endif /* UNIV_DEBUG */
/** The latest known WSREP XID UUID */
static unsigned char wsrep_uuid[16];
Expand All @@ -58,7 +58,7 @@ trx_rseg_update_wsrep_checkpoint(

#ifdef UNIV_DEBUG
/* Check that seqno is monotonically increasing */
wsrep_seqno_t xid_seqno = wsrep_xid_seqno(xid);
long long xid_seqno = wsrep_xid_seqno(xid);
const byte* xid_uuid = wsrep_xid_uuid(xid);

if (!memcmp(xid_uuid, wsrep_uuid, sizeof wsrep_uuid)) {
Expand Down Expand Up @@ -227,7 +227,7 @@ bool trx_rseg_read_wsrep_checkpoint(XID& xid)
}

XID tmp_xid;
wsrep_seqno_t tmp_seqno = 0;
long long tmp_seqno = 0;
if (trx_rseg_read_wsrep_checkpoint(rseg_header, tmp_xid)
&& (tmp_seqno = wsrep_xid_seqno(&tmp_xid))
> max_xid_seqno) {
Expand Down

0 comments on commit 33aad1d

Please sign in to comment.