Skip to content

Commit

Permalink
bzr merge -r3895..3903 lp:codership-mysql/5.5
Browse files Browse the repository at this point in the history
This is just before 5.5.34 merge in wsrep-5.5 branch
  • Loading branch information
Seppo Jaakola committed Nov 26, 2013
1 parent 4a11e84 commit 6422d27
Show file tree
Hide file tree
Showing 16 changed files with 316 additions and 208 deletions.
31 changes: 0 additions & 31 deletions mysys/my_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,6 @@ static my_bool defaults_already_read= FALSE;
/* The only purpose of this global array is to hold full name of my.cnf
* which seems to be otherwise unavailable */
char wsrep_defaults_file[FN_REFLEN + 10]={0,};
/* Command-line only option to start a new wsrep service instance */
#define WSREP_NEW_CLUSTER1 "--wsrep-new-cluster"
#define WSREP_NEW_CLUSTER2 "--wsrep_new_cluster"
/* This one is set to true when --wsrep-new-cluster is found in the command
* line arguments */
my_bool wsrep_new_cluster= FALSE;
/* Finds and removes --wsrep-new-cluster from the arguments list.
* Returns true if found. */
static my_bool find_wsrep_new_cluster (int* argc, char* argv[])
{
my_bool ret= FALSE;
int i;

for (i= *argc - 1; i > 0; i--)
{
if (!strcmp(argv[i], WSREP_NEW_CLUSTER1) ||
!strcmp(argv[i], WSREP_NEW_CLUSTER2))
{
ret= TRUE;
*argc -= 1;
/* preserve the order of remaining arguments */
memmove(&argv[i], &argv[i + 1], (*argc - i)*sizeof(argv[i]));
argv[*argc]= NULL;
}
}

return ret;
}
#endif /* WITH_WREP */

/* Which directories are searched for options (and in which order) */
Expand Down Expand Up @@ -558,9 +530,6 @@ int my_load_defaults(const char *conf_file, const char **groups,
init_alloc_root(&alloc, 512, 0, MYF(0));
if ((dirs= init_default_directories(&alloc)) == NULL)
goto err;
#ifdef WITH_WSREP
wsrep_new_cluster= find_wsrep_new_cluster(argc, argv[0]);
#endif /* WITH_WSREP */
/*
Check if the user doesn't want any default option processing
--no-defaults is always the first option
Expand Down
25 changes: 8 additions & 17 deletions sql/handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1303,11 +1303,7 @@ int ha_commit_trans(THD *thd, bool all)
Free resources and perform other cleanup even for 'empty' transactions.
*/
if (is_real_trans)
#ifdef WITH_WSREP
thd->transaction.cleanup(thd);
#else
thd->transaction.cleanup();
#endif /* WITH_WSREP */
DBUG_RETURN(0);
}

Expand Down Expand Up @@ -1388,6 +1384,7 @@ int ha_commit_trans(THD *thd, bool all)
status_var_increment(thd->status_var.ha_prepare_count);
if (err)
#ifdef WITH_WSREP
{
if (WSREP(thd) && ht->db_type== DB_TYPE_WSREP)
{
error= 1;
Expand All @@ -1397,10 +1394,13 @@ int ha_commit_trans(THD *thd, bool all)
my_error(ER_LOCK_DEADLOCK, MYF(0), err);
}
}
else
else
/* not wsrep hton, bail to native mysql behavior */
#endif
#endif /* WITH_WSREP */
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
#ifdef WITH_WSREP
}
#endif /* WITH_WSREP */

if (err)
goto err;
Expand Down Expand Up @@ -1535,12 +1535,7 @@ commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, bool is_real_trans)
}
/* Free resources and perform other cleanup even for 'empty' transactions. */
if (is_real_trans)
#ifdef WITH_WSREP
thd->transaction.cleanup(thd);
#else
thd->transaction.cleanup();
#endif /* WITH_WSREP */

thd->transaction.cleanup();
DBUG_RETURN(error);
}

Expand Down Expand Up @@ -1614,11 +1609,7 @@ int ha_rollback_trans(THD *thd, bool all)
}
/* Always cleanup. Even if nht==0. There may be savepoints. */
if (is_real_trans)
#ifdef WITH_WSREP
thd->transaction.cleanup(thd);
#else
thd->transaction.cleanup();
#endif /* WITH_WSREP */
thd->transaction.cleanup();
if (all)
thd->transaction_rollback_request= FALSE;

Expand Down
15 changes: 2 additions & 13 deletions sql/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,20 +548,9 @@ IO_CACHE * get_trans_log(THD * thd)

bool wsrep_trans_cache_is_empty(THD *thd)
{
bool res= TRUE;

if (thd_sql_command((const THD*) thd) != SQLCOM_SELECT)
res= FALSE;
else
{
binlog_cache_mngr *const cache_mngr=
binlog_cache_mngr *const cache_mngr=
(binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
if (cache_mngr)
{
res= cache_mngr->trx_cache.empty();
}
}
return res;
return (!cache_mngr || cache_mngr->trx_cache.empty());
}

void thd_binlog_flush_pending_rows_event(THD *thd, bool stmt_end)
Expand Down
4 changes: 4 additions & 0 deletions sql/mysqld.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#include "debug_sync.h"
#ifdef WITH_WSREP
#include "wsrep_mysqld.h"
#include "wsrep_var.h"
#include "wsrep_thd.h"
#include "wsrep_sst.h"
ulong wsrep_running_threads = 0; // # of currently running wsrep threads
Expand Down Expand Up @@ -5705,6 +5706,9 @@ int mysqld_main(int argc, char **argv)
return 1;
}
#endif
#ifdef WITH_WSREP
wsrep_filter_new_cluster (&argc, argv);
#endif /* WITH_WSREP */

orig_argc= argc;
orig_argv= argv;
Expand Down
6 changes: 2 additions & 4 deletions sql/sql_class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ extern "C" const char *wsrep_thd_exec_mode_str(THD *thd)
(!thd) ? "void" :
(thd->wsrep_exec_mode == LOCAL_STATE) ? "local" :
(thd->wsrep_exec_mode == REPL_RECV) ? "applier" :
(thd->wsrep_exec_mode == TOTAL_ORDER) ? "total order" :
(thd->wsrep_exec_mode == TOTAL_ORDER) ? "total order" :
(thd->wsrep_exec_mode == LOCAL_COMMIT) ? "local commit" : "void";
}

Expand Down Expand Up @@ -896,7 +896,7 @@ extern "C" my_thread_id wsrep_thd_thread_id(THD *thd)
}
extern "C" wsrep_seqno_t wsrep_thd_trx_seqno(THD *thd)
{
return (thd) ? thd->wsrep_trx_meta.gtid.seqno : -1;
return (thd) ? thd->wsrep_trx_meta.gtid.seqno : WSREP_SEQNO_UNDEFINED;
}
extern "C" query_id_t wsrep_thd_query_id(THD *thd)
{
Expand Down Expand Up @@ -1145,7 +1145,6 @@ THD::THD()
wsrep_ws_handle.opaque = NULL;
wsrep_retry_counter = 0;
wsrep_PA_safe = true;
wsrep_seqno_changed = false;
wsrep_retry_query = NULL;
wsrep_retry_query_len = 0;
wsrep_retry_command = COM_CONNECT;
Expand Down Expand Up @@ -1552,7 +1551,6 @@ void THD::init(void)
wsrep_retry_counter= 0;
wsrep_rli= NULL;
wsrep_PA_safe= true;
wsrep_seqno_changed= false;
wsrep_consistency_check = NO_CONSISTENCY_CHECK;
wsrep_mysql_replicated = 0;

Expand Down
13 changes: 0 additions & 13 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -1038,9 +1038,6 @@ struct st_savepoint {
/** State of metadata locks before this savepoint was set. */
MDL_savepoint mdl_savepoint;
};
#ifdef WITH_WSREP
void wsrep_cleanup_transaction(THD *thd); // THD.transactions.cleanup calls it
#endif

enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED, XA_ROLLBACK_ONLY};
extern const char *xa_state_names[];
Expand Down Expand Up @@ -1984,11 +1981,7 @@ class THD :public Statement,
*/
CHANGED_TABLE_LIST* changed_tables;
MEM_ROOT mem_root; // Transaction-life memory allocation pool
#ifdef WITH_WSREP
void cleanup(THD *thd)
#else
void cleanup()
#endif
{
DBUG_ENTER("thd::cleanup");
changed_tables= 0;
Expand All @@ -2002,11 +1995,6 @@ class THD :public Statement,
if (!xid_state.rm_error)
xid_state.xid.null();
free_root(&mem_root,MYF(MY_KEEP_PREALLOC));
#ifdef WITH_WSREP
// Todo: convert into a plugin method
// wsrep's post-commit. LOCAL_COMMIT designates wsrep's commit was ok
if (WSREP(thd)) wsrep_cleanup_transaction(thd);
#endif /* WITH_WSREP */
DBUG_VOID_RETURN;
}
my_bool is_active()
Expand Down Expand Up @@ -2560,7 +2548,6 @@ class THD :public Statement,
Relay_log_info* wsrep_rli;
bool wsrep_converted_lock_session;
wsrep_ws_handle_t wsrep_ws_handle;
bool wsrep_seqno_changed;
#ifdef WSREP_PROC_INFO
char wsrep_info[128]; /* string for dynamic proc info */
#endif /* WSREP_PROC_INFO */
Expand Down
23 changes: 17 additions & 6 deletions sql/sql_parse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4629,7 +4629,20 @@ case SQLCOM_PREPARE:
thd->killed= KILL_CONNECTION;
thd->print_aborted_warning(3, "RELEASE");
}
#ifdef WITH_WSREP
if (WSREP(thd)) {

if (thd->wsrep_conflict_state == NO_CONFLICT ||
thd->wsrep_conflict_state == REPLAYING)
{
my_ok(thd);
}
} else {
#endif /* WITH_WSREP */
my_ok(thd);
#ifdef WITH_WSREP
}
#endif /* WITH_WSREP */
break;
}
case SQLCOM_ROLLBACK:
Expand Down Expand Up @@ -4664,17 +4677,15 @@ case SQLCOM_PREPARE:
/* Disconnect the current client connection. */
if (tx_release)
thd->killed= KILL_CONNECTION;
#ifdef WITH_WSREP
#ifdef WITH_WSREP
if (WSREP(thd)) {
if (thd->wsrep_conflict_state == NO_CONFLICT ||
thd->wsrep_conflict_state == REPLAYING)
{
if (thd->wsrep_conflict_state == NO_CONFLICT) {
my_ok(thd);
}
} else {
#endif /* WITH_WSREP */
my_ok(thd);
#ifdef WITH_WSREP
#ifdef WITH_WSREP
}
#endif /* WITH_WSREP */
break;
Expand Down Expand Up @@ -5156,7 +5167,7 @@ case SQLCOM_PREPARE:
if (check_table_access(thd, DROP_ACL, all_tables, FALSE, UINT_MAX, FALSE))
goto error;
/* Conditionally writes to binlog. */
WSREP_TO_ISOLATION_BEGIN(NULL, NULL, NULL)
WSREP_TO_ISOLATION_BEGIN(WSREP_MYSQL_DB, NULL, NULL)
res= mysql_drop_view(thd, first_table, thd->lex->drop_mode);
break;
}
Expand Down
18 changes: 17 additions & 1 deletion sql/transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ bool trans_begin(THD *thd, uint flags)
~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS"));
res= test(ha_commit_trans(thd, TRUE));
#ifdef WITH_WSREP
wsrep_post_commit(thd, TRUE);
#endif /* WITH_WSREP */
}

thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
Expand Down Expand Up @@ -226,6 +229,9 @@ bool trans_commit(THD *thd)
~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS"));
res= ha_commit_trans(thd, TRUE);
#ifdef WITH_WSREP
wsrep_post_commit(thd, TRUE);
#endif /* WITH_WSREP */
/*
if res is non-zero, then ha_commit_trans has rolled back the
transaction, so the hooks for rollback will be called.
Expand Down Expand Up @@ -274,6 +280,9 @@ bool trans_commit_implicit(THD *thd)
~(SERVER_STATUS_IN_TRANS | SERVER_STATUS_IN_TRANS_READONLY);
DBUG_PRINT("info", ("clearing SERVER_STATUS_IN_TRANS"));
res= test(ha_commit_trans(thd, TRUE));
#ifdef WITH_WSREP
wsrep_post_commit(thd, TRUE);
#endif /* WITH_WSREP */
}

thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
Expand Down Expand Up @@ -362,10 +371,14 @@ bool trans_commit_stmt(THD *thd)
#endif /* WITH_WSREP */
res= ha_commit_trans(thd, FALSE);
if (! thd->in_active_multi_stmt_transaction())
#ifdef WITH_WSREP
{
#endif /* WITH_WSREP */
thd->tx_isolation= (enum_tx_isolation) thd->variables.tx_isolation;
thd->tx_read_only= thd->variables.tx_read_only;
#ifdef WITH_WSREP
wsrep_post_commit(thd, FALSE);
}
#endif /* WITH_WSREP */
}

/*
Expand Down Expand Up @@ -781,6 +794,9 @@ bool trans_xa_commit(THD *thd)
int r= ha_commit_trans(thd, TRUE);
if ((res= test(r)))
my_error(r == 1 ? ER_XA_RBROLLBACK : ER_XAER_RMERR, MYF(0));
#ifdef WITH_WSREP
wsrep_post_commit(thd, TRUE);
#endif /* WITH_WSREP */
}
else if (xa_state == XA_PREPARED && thd->lex->xa_opt == XA_NONE)
{
Expand Down
Loading

0 comments on commit 6422d27

Please sign in to comment.