From b098b7a84c374ee7e5a133cbf16be643609c1543 Mon Sep 17 00:00:00 2001 From: Seppo Jaakola Date: Wed, 27 Nov 2013 00:18:44 +0200 Subject: bzr merge -r3904..3928 lp:codership-mysql/5.5 This is now otherwise on level wsrep-25.9, but storage/innobase has not been fully merged wsrep-5.5 is not good source for that, so we probably have to cherry pick innodb changes from wsrep-5.6 --- wsrep/CMakeLists.txt | 24 ------ wsrep/Makefile.am | 2 - wsrep/wsrep_api.h | 14 ++-- wsrep/wsrep_dummy.c | 56 ++++++++------ wsrep/wsrep_loader.c | 203 --------------------------------------------------- wsrep/wsrep_uuid.c | 83 --------------------- 6 files changed, 41 insertions(+), 341 deletions(-) delete mode 100644 wsrep/CMakeLists.txt delete mode 100644 wsrep/Makefile.am delete mode 100644 wsrep/wsrep_loader.c delete mode 100644 wsrep/wsrep_uuid.c (limited to 'wsrep') diff --git a/wsrep/CMakeLists.txt b/wsrep/CMakeLists.txt deleted file mode 100644 index 11d0e34d1b0..00000000000 --- a/wsrep/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (c) 2012, Codership Oy. All rights reserved. -# -# This program 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; version 2 of the License. -# -# This program 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 this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -INCLUDE_DIRECTORIES( "." ) - -SET(WSREP_SOURCES wsrep_uuid.c wsrep_loader.c wsrep_dummy.c) - -ADD_CONVENIENCE_LIBRARY(wsrep ${WSREP_SOURCES}) -DTRACE_INSTRUMENT(wsrep) - -#ADD_EXECUTABLE(listener wsrep_listener.c ${WSREP_SOURCES}) -#TARGET_LINK_LIBRARIES(listener ${LIBDL}) diff --git a/wsrep/Makefile.am b/wsrep/Makefile.am deleted file mode 100644 index 40e4b501e86..00000000000 --- a/wsrep/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -noinst_LIBRARIES = libwsrep.a -libwsrep_a_SOURCES = wsrep_api.h wsrep_loader.c wsrep_dummy.c wsrep_uuid.c diff --git a/wsrep/wsrep_api.h b/wsrep/wsrep_api.h index 987a47db578..f713de66d57 100644 --- a/wsrep/wsrep_api.h +++ b/wsrep/wsrep_api.h @@ -63,7 +63,7 @@ extern "C" { * * **************************************************************************/ -#define WSREP_INTERFACE_VERSION "24" +#define WSREP_INTERFACE_VERSION "25" /*! Empty backend spec */ #define WSREP_NONE "none" @@ -118,8 +118,8 @@ typedef void (*wsrep_log_cb_t)(wsrep_log_level_t, const char *); * * COMMIT the writeset and all preceding writesets must be committed * ROLLBACK all preceding writesets in a transaction must be rolled back - * PA_UNSAFE the writeset cannot be applied in parallel * ISOLATION the writeset must be applied AND committed in isolation + * PA_UNSAFE the writeset cannot be applied in parallel * COMMUTATIVE the order in which the writeset is applied does not matter * NATIVE the writeset contains another writeset in this provider format * @@ -128,8 +128,8 @@ typedef void (*wsrep_log_cb_t)(wsrep_log_level_t, const char *); */ #define WSREP_FLAG_COMMIT ( 1ULL << 0 ) #define WSREP_FLAG_ROLLBACK ( 1ULL << 1 ) -#define WSREP_FLAG_PA_UNSAFE ( 1ULL << 3 ) #define WSREP_FLAG_ISOLATION ( 1ULL << 2 ) +#define WSREP_FLAG_PA_UNSAFE ( 1ULL << 3 ) #define WSREP_FLAG_COMMUTATIVE ( 1ULL << 4 ) #define WSREP_FLAG_NATIVE ( 1ULL << 5 ) @@ -349,6 +349,7 @@ typedef enum wsrep_cb_status (*wsrep_view_cb_t) ( * @param recv_ctx receiver context pointer provided by the application * @param data data buffer containing the writeset * @param size data buffer size + * @param flags WSREP_FLAG_... flags * @param meta transaction meta data of the writeset to be applied * * @return success code: @@ -360,6 +361,7 @@ typedef enum wsrep_cb_status (*wsrep_apply_cb_t) ( void* recv_ctx, const void* data, size_t size, + uint32_t flags, const wsrep_trx_meta_t* meta ); @@ -370,6 +372,7 @@ typedef enum wsrep_cb_status (*wsrep_apply_cb_t) ( * This handler is called to commit the changes made by apply callback. * * @param recv_ctx receiver context pointer provided by the application + * @param flags WSREP_FLAG_... flags * @param meta transaction meta data of the writeset to be committed * @param exit set to true to exit recv loop * @param commit true - commit writeset, false - rollback writeset @@ -380,6 +383,7 @@ typedef enum wsrep_cb_status (*wsrep_apply_cb_t) ( */ typedef enum wsrep_cb_status (*wsrep_commit_cb_t) ( void* recv_ctx, + uint32_t flags, const wsrep_trx_meta_t* meta, wsrep_bool_t* exit, wsrep_bool_t commit @@ -687,7 +691,7 @@ struct wsrep { wsrep_status_t (*pre_commit)(wsrep_t* wsrep, wsrep_conn_id_t conn_id, wsrep_ws_handle_t* ws_handle, - uint64_t flags, + uint32_t flags, wsrep_trx_meta_t* meta); /*! @@ -913,7 +917,7 @@ struct wsrep { wsrep_status_t (*preordered_commit) (wsrep_t* wsrep, wsrep_po_handle_t* handle, const wsrep_uuid_t* source_id, - uint64_t flags, + uint32_t flags, int pa_range, wsrep_bool_t commit); diff --git a/wsrep/wsrep_dummy.c b/wsrep/wsrep_dummy.c index 33b61e6821f..3c7a7c2e354 100644 --- a/wsrep/wsrep_dummy.c +++ b/wsrep/wsrep_dummy.c @@ -101,9 +101,7 @@ static wsrep_status_t dummy_pre_commit( wsrep_t* w, const wsrep_conn_id_t conn_id __attribute__((unused)), wsrep_ws_handle_t* ws_handle __attribute__((unused)), -// const struct wsrep_buf* data __attribute__((unused)), -// const long count __attribute__((unused)), - uint64_t flags __attribute__((unused)), + uint32_t flags __attribute__((unused)), wsrep_trx_meta_t* meta __attribute__((unused))) { WSREP_DBUG_ENTER(w); @@ -148,7 +146,7 @@ static wsrep_status_t dummy_append_key( wsrep_t* w, wsrep_ws_handle_t* ws_handle __attribute__((unused)), const wsrep_key_t* key __attribute__((unused)), - const int key_num __attribute__((unused)), + const size_t key_num __attribute__((unused)), const wsrep_key_type_t key_type __attribute__((unused)), const bool copy __attribute__((unused))) { @@ -160,7 +158,7 @@ static wsrep_status_t dummy_append_data( wsrep_t* w, wsrep_ws_handle_t* ws_handle __attribute__((unused)), const struct wsrep_buf* data __attribute__((unused)), - const int count __attribute__((unused)), + const size_t count __attribute__((unused)), const wsrep_data_type_t type __attribute__((unused)), const bool copy __attribute__((unused))) { @@ -188,9 +186,9 @@ static wsrep_status_t dummy_to_execute_start( wsrep_t* w, const wsrep_conn_id_t conn_id __attribute__((unused)), const wsrep_key_t* key __attribute__((unused)), - const int key_num __attribute__((unused)), + const size_t key_num __attribute__((unused)), const struct wsrep_buf* data __attribute__((unused)), - const int count __attribute__((unused)), + const size_t count __attribute__((unused)), wsrep_trx_meta_t* meta __attribute__((unused))) { WSREP_DBUG_ENTER(w); @@ -205,14 +203,24 @@ static wsrep_status_t dummy_to_execute_end( return WSREP_OK; } -static wsrep_status_t dummy_preordered( - wsrep_t* w, - const wsrep_uuid_t* source_id __attribute__((unused)), - int pa_range __attribute__((unused)), - const struct wsrep_buf* data __attribute__((unused)), - int count __attribute__((unused)), - uint64_t flags __attribute__((unused)), - wsrep_bool_t copy __attribute__((unused))) +static wsrep_status_t dummy_preordered_collect( + wsrep_t* w, + wsrep_po_handle_t* handle __attribute__((unused)), + const struct wsrep_buf* data __attribute__((unused)), + size_t count __attribute__((unused)), + wsrep_bool_t copy __attribute__((unused))) +{ + WSREP_DBUG_ENTER(w); + return WSREP_OK; +} + +static wsrep_status_t dummy_preordered_commit( + wsrep_t* w, + wsrep_po_handle_t* handle __attribute__((unused)), + const wsrep_uuid_t* source_id __attribute__((unused)), + uint32_t flags __attribute__((unused)), + int pa_range __attribute__((unused)), + wsrep_bool_t commit __attribute__((unused))) { WSREP_DBUG_ENTER(w); return WSREP_OK; @@ -220,8 +228,8 @@ static wsrep_status_t dummy_preordered( static wsrep_status_t dummy_sst_sent( wsrep_t* w, - const wsrep_uuid_t* uuid __attribute__((unused)), - wsrep_seqno_t seqno __attribute__((unused))) + const wsrep_gtid_t* state_id __attribute__((unused)), + const int rcode __attribute__((unused))) { WSREP_DBUG_ENTER(w); return WSREP_OK; @@ -229,10 +237,10 @@ static wsrep_status_t dummy_sst_sent( static wsrep_status_t dummy_sst_received( wsrep_t* w, - const wsrep_uuid_t* uuid __attribute__((unused)), - const wsrep_seqno_t seqno __attribute__((unused)), - const char* state __attribute__((unused)), - const size_t state_len __attribute__((unused))) + const wsrep_gtid_t* state_id __attribute__((unused)), + const void* state __attribute__((unused)), + const size_t state_len __attribute__((unused)), + const int rcode __attribute__((unused))) { WSREP_DBUG_ENTER(w); return WSREP_OK; @@ -241,7 +249,7 @@ static wsrep_status_t dummy_sst_received( static wsrep_status_t dummy_snapshot( wsrep_t* w, const void* msg __attribute__((unused)), - const int msg_len __attribute__((unused)), + const size_t msg_len __attribute__((unused)), const char* donor_spec __attribute__((unused))) { WSREP_DBUG_ENTER(w); @@ -341,7 +349,8 @@ static wsrep_t dummy_iface = { &dummy_free_connection, &dummy_to_execute_start, &dummy_to_execute_end, - &dummy_preordered, + &dummy_preordered_collect, + &dummy_preordered_commit, &dummy_sst_sent, &dummy_sst_received, &dummy_snapshot, @@ -358,7 +367,6 @@ static wsrep_t dummy_iface = { WSREP_NONE, WSREP_INTERFACE_VERSION, "Codership Oy ", - 0xdeadbeef, &dummy_free, NULL, NULL diff --git a/wsrep/wsrep_loader.c b/wsrep/wsrep_loader.c deleted file mode 100644 index 8ae6ea962ec..00000000000 --- a/wsrep/wsrep_loader.c +++ /dev/null @@ -1,203 +0,0 @@ -/* Copyright (C) 2009-2011 Codership Oy - - This program 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; version 2 of the License. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*! @file wsrep implementation loader */ - -#include -#include -#include -#include - -#include "wsrep_api.h" - -// Logging stuff for the loader -static const char* log_levels[] = {"FATAL", "ERROR", "WARN", "INFO", "DEBUG"}; - -static void default_logger (wsrep_log_level_t lvl, const char* msg) -{ - fprintf (stderr, "wsrep loader: [%s] %s\n", log_levels[lvl], msg); -} - -static wsrep_log_cb_t logger = default_logger; - -/************************************************************************** - * Library loader - **************************************************************************/ - -static int verify(const wsrep_t *wh, const char *iface_ver) -{ - const size_t msg_len = 128; - char msg[msg_len]; - -#define VERIFY(_p) if (!(_p)) { \ - snprintf(msg, msg_len, "wsrep_load(): verify(): %s\n", # _p); \ - logger (WSREP_LOG_ERROR, msg); \ - return EINVAL; \ - } - - VERIFY(wh); - VERIFY(wh->version); - - if (strcmp(wh->version, iface_ver)) { - snprintf (msg, msg_len, - "provider interface version mismatch: need '%s', found '%s'", - iface_ver, wh->version); - logger (WSREP_LOG_ERROR, msg); - return EINVAL; - } - - VERIFY(wh->init); - VERIFY(wh->options_set); - VERIFY(wh->options_get); - VERIFY(wh->connect); - VERIFY(wh->disconnect); - VERIFY(wh->recv); - VERIFY(wh->pre_commit); - VERIFY(wh->post_commit); - VERIFY(wh->post_rollback); - VERIFY(wh->replay_trx); - VERIFY(wh->abort_pre_commit); - VERIFY(wh->append_key); - VERIFY(wh->append_data); - VERIFY(wh->free_connection); - VERIFY(wh->to_execute_start); - VERIFY(wh->to_execute_end); - VERIFY(wh->preordered_collect); - VERIFY(wh->preordered_commit); - VERIFY(wh->sst_sent); - VERIFY(wh->sst_received); - VERIFY(wh->stats_get); - VERIFY(wh->stats_free); - VERIFY(wh->stats_reset); - VERIFY(wh->pause); - VERIFY(wh->resume); - VERIFY(wh->desync); - VERIFY(wh->resync); - VERIFY(wh->lock); - VERIFY(wh->unlock); - VERIFY(wh->is_locked); - VERIFY(wh->provider_name); - VERIFY(wh->provider_version); - VERIFY(wh->provider_vendor); - VERIFY(wh->free); - return 0; -} - -typedef int (*wsrep_loader_fun)(wsrep_t*); - -static wsrep_loader_fun wsrep_dlf(void *dlh, const char *sym) -{ - union { - wsrep_loader_fun dlfun; - void *obj; - } alias; - alias.obj = dlsym(dlh, sym); - return alias.dlfun; -} - -extern int wsrep_dummy_loader(wsrep_t *w); - -int wsrep_load(const char *spec, wsrep_t **hptr, wsrep_log_cb_t log_cb) -{ - int ret = 0; - void *dlh = NULL; - wsrep_loader_fun dlfun; - const size_t msg_len = 1024; - char msg[msg_len + 1]; - msg[msg_len] = 0; - - if (NULL != log_cb) - logger = log_cb; - - if (!(spec && hptr)) - return EINVAL; - - snprintf (msg, msg_len, - "wsrep_load(): loading provider library '%s'", spec); - logger (WSREP_LOG_INFO, msg); - - if (!(*hptr = malloc(sizeof(wsrep_t)))) { - logger (WSREP_LOG_FATAL, "wsrep_load(): out of memory"); - return ENOMEM; - } - - if (!spec || strcmp(spec, WSREP_NONE) == 0) { - if ((ret = wsrep_dummy_loader(*hptr)) != 0) { - free (*hptr); - *hptr = NULL; - } - return ret; - } - - if (!(dlh = dlopen(spec, RTLD_NOW | RTLD_LOCAL))) { - snprintf(msg, msg_len, "wsrep_load(): dlopen(): %s", dlerror()); - logger (WSREP_LOG_ERROR, msg); - ret = EINVAL; - goto out; - } - - if (!(dlfun = wsrep_dlf(dlh, "wsrep_loader"))) { - ret = EINVAL; - goto out; - } - - if ((ret = (*dlfun)(*hptr)) != 0) { - snprintf(msg, msg_len, "wsrep_load(): loader failed: %s", - strerror(ret)); - logger (WSREP_LOG_ERROR, msg); - goto out; - } - - if ((ret = verify(*hptr, WSREP_INTERFACE_VERSION)) != 0) { - snprintf (msg, msg_len, - "wsrep_load(): interface version mismatch: my version %s, " - "provider version %s", WSREP_INTERFACE_VERSION, - (*hptr)->version); - logger (WSREP_LOG_ERROR, msg); - goto out; - } - - (*hptr)->dlh = dlh; - -out: - if (ret != 0) { - if (dlh) dlclose(dlh); - free(*hptr); - *hptr = NULL; - } else { - snprintf (msg, msg_len, - "wsrep_load(): %s %s by %s loaded successfully.", - (*hptr)->provider_name, (*hptr)->provider_version, - (*hptr)->provider_vendor); - logger (WSREP_LOG_INFO, msg); - } - - return ret; -} - -void wsrep_unload(wsrep_t *hptr) -{ - if (!hptr) { - logger (WSREP_LOG_WARN, "wsrep_unload(): null pointer."); - } else { - if (hptr->free) - hptr->free(hptr); - if (hptr->dlh) - dlclose(hptr->dlh); - free(hptr); - } -} - diff --git a/wsrep/wsrep_uuid.c b/wsrep/wsrep_uuid.c deleted file mode 100644 index baa95b2578a..00000000000 --- a/wsrep/wsrep_uuid.c +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (C) 2009 Codership Oy - - This program 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; version 2 of the License. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/*! @file Helper functions to deal with history UUID string representations */ - -#include -#include -#include - -#include "wsrep_api.h" - -/*! - * Read UUID from string - * @return length of UUID string representation or -EINVAL in case of error - */ -int -wsrep_uuid_scan (const char* str, size_t str_len, wsrep_uuid_t* uuid) -{ - unsigned int uuid_len = 0; - unsigned int uuid_offt = 0; - - while (uuid_len + 1 < str_len) { - /* We are skipping potential '-' after uuid_offt == 4, 6, 8, 10 - * which means - * (uuid_offt >> 1) == 2, 3, 4, 5, - * which in turn means - * (uuid_offt >> 1) - 2 <= 3 - * since it is always >= 0, because uuid_offt is unsigned */ - if (((uuid_offt >> 1) - 2) <= 3 && str[uuid_len] == '-') { - // skip dashes after 4th, 6th, 8th and 10th positions - uuid_len += 1; - continue; - } - - if (isxdigit(str[uuid_len]) && isxdigit(str[uuid_len + 1])) { - // got hex digit, scan another byte to uuid, increment uuid_offt - sscanf (str + uuid_len, "%2hhx", uuid->data + uuid_offt); - uuid_len += 2; - uuid_offt += 1; - if (sizeof (uuid->data) == uuid_offt) - return uuid_len; - } - else { - break; - } - } - - *uuid = WSREP_UUID_UNDEFINED; - return -EINVAL; -} - -/*! - * Write UUID to string - * @return length of UUID string representation or -EMSGSIZE if string is too - * short - */ -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; - } -} -- cgit v1.2.1