* Merged revisions 3945, 3946..3950, 3951..3961

from codership-mysql/5.5.
* Merged changes in innobase to xtradb.
* Updated WSREP_PATCH_REVNO.
This commit is contained in:
Nirbhay Choubey 2014-02-28 13:56:08 -05:00
parent ae6e1548cb
commit c3a2394641
20 changed files with 130 additions and 81 deletions

View file

@ -23,7 +23,7 @@ SET(WSREP_PATCH_VERSION "9")
# MariaDB addition: Revision number of the last revision merged from
# codership branch visible in @@visible_comment.
# Branch : codership-mysql/5.5
SET(WSREP_PATCH_REVNO "3944") # Should be updated on every merge.
SET(WSREP_PATCH_REVNO "3961") # Should be updated on every merge.
# MariaDB: Obtain patch revision number:
# Update WSREP_PATCH_REVNO if WSREP_REV environment variable is set.

View file

@ -3,12 +3,12 @@
[mysqld.1]
binlog-format=row
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_address='gcomm://'
[mysqld.2]
binlog-format=row
wsrep_provider=/usr/lib/libgalera_smm.so
wsrep_provider=/usr/lib/galera/libgalera_smm.so
wsrep_cluster_address='gcomm://127.0.0.1:4567'
wsrep_provider_options='gmcast.listen_addr=tcp://127.0.0.1:4568'

View file

@ -1 +1 @@
--binlog-format=row --innodb_autoinc_lock_mode=2 --innodb_locks_unsafe_for_binlog=1 --wsrep-provider=/usr/lib/libgalera_smm.so --wsrep-cluster-address=gcomm:// --wsrep-on=1 --log-bin
--binlog-format=row --innodb_autoinc_lock_mode=2 --innodb_locks_unsafe_for_binlog=1 --wsrep-provider=/usr/lib/galera/libgalera_smm.so --wsrep-cluster-address=gcomm:// --wsrep-on=1 --log-bin

View file

@ -67,12 +67,22 @@ check_pid_and_port()
MAGIC_FILE="$WSREP_SST_OPT_DATA/rsync_sst_complete"
rm -rf "$MAGIC_FILE"
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd -P)
WSREP_LOG_DIR=${WSREP_LOG_DIR:-$($SCRIPT_DIR/my_print_defaults --defaults-file "$WSREP_SST_OPT_CONF" mysqld server mysqld-5.5 \
| grep -- '--innodb[-_]log[-_]group[-_]home[-_]dir=' | cut -b 29- )}
if [ -n "${WSREP_LOG_DIR:-""}" ]; then
WSREP_LOG_DIR=${WSREP_LOG_DIR:-""}
# if WSREP_LOG_DIR env. variable is not set, try to get it from my.cnf
if [ -z "$WSREP_LOG_DIR" ]; then
SCRIPT_DIR="$(cd $(dirname "$0"); pwd -P)"
WSREP_LOG_DIR=$($SCRIPT_DIR/my_print_defaults --defaults-file \
"$WSREP_SST_OPT_CONF" mysqld server mysqld-5.5 \
| grep -- '--innodb[-_]log[-_]group[-_]home[-_]dir=' \
| cut -b 29- )
fi
if [ -n "$WSREP_LOG_DIR" ]; then
# handle both relative and absolute paths
WSREP_LOG_DIR=$(cd $WSREP_SST_OPT_DATA; mkdir -p "$WSREP_LOG_DIR"; cd $WSREP_LOG_DIR; pwd -P)
else
# default to datadir
WSREP_LOG_DIR=$(cd $WSREP_SST_OPT_DATA; pwd -P)
fi
@ -158,7 +168,7 @@ then
find . -maxdepth 1 -mindepth 1 -type d -print0 | xargs -I{} -0 -P $count \
rsync --owner --group --perms --links --specials \
--ignore-times --inplace --recursive --delete --quiet \
$WHOLE_FILE_OPT --exclude '*/ib_logfile*' "$WSREP_SST_OPT_DATA"/{}/ \
$WHOLE_FILE_OPT --exclude '*/ib_logfile*' "$WSREP_SST_OPT_DATA"/{}/ \
rsync://$WSREP_SST_OPT_ADDR/{} >&2 || RC=$?
popd >/dev/null
@ -208,8 +218,6 @@ then
trap "exit 3" INT TERM ABRT
trap cleanup_joiner EXIT
MYUID=$(id -u)
MYGID=$(id -g)
RSYNC_CONF="$WSREP_SST_OPT_DATA/$MODULE.conf"
cat << EOF > "$RSYNC_CONF"
@ -217,8 +225,6 @@ pid file = $RSYNC_PID
use chroot = no
read only = no
timeout = 300
uid = $MYUID
gid = $MYGID
[$MODULE]
path = $WSREP_SST_OPT_DATA
[$MODULE-log_dir]

View file

@ -308,7 +308,13 @@ const char *ha_partition::table_type() const
// we can do this since we only support a single engine type
return m_file && m_file[0] ? m_file[0]->table_type() : "Unknown";
}
#ifdef WITH_WSREP
int ha_partition::wsrep_db_type() const
{
// we can do this since we only support a single engine type
return ha_legacy_type(m_file[0]->ht);
}
#endif /* WITH_WSREP */
/*
Destructor method

View file

@ -1178,6 +1178,7 @@ public:
for (uint i=0; i < m_tot_parts; i++)
m_file[i]->ha_start_of_new_statement();
}
virtual int wsrep_db_type() const;
#endif /* WITH_WSREP */
};

View file

@ -1302,18 +1302,27 @@ int ha_commit_trans(THD *thd, bool all)
if (err)
{
#ifdef WITH_WSREP
if (WSREP(thd) && ht->db_type== DB_TYPE_WSREP)
{
error= 1;
/* avoid sending error, if we need to replay */
if (thd->wsrep_conflict_state!= MUST_REPLAY)
{
my_error(ER_LOCK_DEADLOCK, MYF(0), err);
}
}
else
{
/* not wsrep hton, bail to native mysql behavior */
if (WSREP(thd) && ht->db_type== DB_TYPE_WSREP)
{
error= 1;
switch (err)
{
case WSREP_TRX_SIZE_EXCEEDED:
/* give user size exeeded erro from wsrep_api.h */
my_error(ER_ERROR_DURING_COMMIT, MYF(0), WSREP_SIZE_EXCEEDED);
break;
case WSREP_TRX_CERT_FAIL:
case WSREP_TRX_ERROR:
/* avoid sending error, if we need to replay */
if (thd->wsrep_conflict_state!= MUST_REPLAY)
{
my_error(ER_LOCK_DEADLOCK, MYF(0), err);
}
}
}
else
{
/* not wsrep hton, bail to native mysql behavior */
#endif /* WITH_WSREP */
my_error(ER_ERROR_DURING_COMMIT, MYF(0), err);
error= 1;
@ -5119,6 +5128,17 @@ static int binlog_log_row(TABLE* table,
bool error= 0;
THD *const thd= table->in_use;
#ifdef WITH_WSREP
/* only InnoDB tables will be replicated through binlog emulation */
if (WSREP_EMULATE_BINLOG(thd) &&
table->file->ht->db_type != DB_TYPE_INNODB &&
!(table->file->ht->db_type == DB_TYPE_PARTITION_DB &&
(((ha_partition*)(table->file))->wsrep_db_type() == DB_TYPE_INNODB)))
// !strcmp(table->file->table_type(), "InnoDB"))
{
return 0;
}
#endif /* WITH_WSREP */
if (check_table_binlog_row_based(thd, table))
{
MY_BITMAP cols;

View file

@ -2829,7 +2829,12 @@ Query_log_event::Query_log_event(THD* thd_arg, const char* query_arg,
{
time_t end_time;
#ifdef WITH_WSREP
thd->wsrep_PA_safe= false;
/*
If Query_log_event will contain non trans keyword (not BEGIN, COMMIT,
SAVEPOINT or ROLLBACK) we disable PA for this transaction.
*/
if (!is_trans_keyword())
thd->wsrep_PA_safe= false;
#endif /* WITH_WSREP */
memset(&user, 0, sizeof(user));
memset(&host, 0, sizeof(host));

View file

@ -4883,7 +4883,7 @@ pthread_handler_t start_wsrep_THD(void *arg)
mysql_mutex_lock(&LOCK_thread_count);
wsrep_running_threads++;
mysql_cond_signal(&COND_thread_count);
mysql_cond_broadcast(&COND_thread_count);
mysql_mutex_unlock(&LOCK_thread_count);
processor(thd);
@ -4893,7 +4893,7 @@ pthread_handler_t start_wsrep_THD(void *arg)
mysql_mutex_lock(&LOCK_thread_count);
wsrep_running_threads--;
WSREP_DEBUG("wsrep running threads now: %lu", wsrep_running_threads);
mysql_cond_signal(&COND_thread_count);
mysql_cond_broadcast(&COND_thread_count);
mysql_mutex_unlock(&LOCK_thread_count);
// Note: We can't call THD destructor without crashing

View file

@ -134,6 +134,19 @@ bool Alter_table_truncate_partition_statement::execute(THD *thd)
if (check_one_table_access(thd, DROP_ACL, first_table))
DBUG_RETURN(TRUE);
#ifdef WITH_WSREP
TABLE *find_temporary_table(THD *thd, const TABLE_LIST *tl);
if ((!thd->is_current_stmt_binlog_format_row() ||
!find_temporary_table(thd, first_table)) &&
wsrep_to_isolation_begin(
thd, first_table->db, first_table->table_name, NULL)
)
{
WSREP_WARN("ALTER TABLE isolation failure");
DBUG_RETURN(TRUE);
}
#endif /* WITH_WSREP */
if (open_and_lock_tables(thd, first_table, FALSE, 0))
DBUG_RETURN(TRUE);

View file

@ -449,6 +449,12 @@ bool Truncate_statement::truncate_table(THD *thd, TABLE_LIST *table_ref)
{
bool hton_can_recreate;
#ifdef WITH_WSREP
if (WSREP(thd) && wsrep_to_isolation_begin(thd,
table_ref->db,
table_ref->table_name, NULL))
DBUG_RETURN(TRUE);
#endif /* WITH_WSREP */
if (lock_table(thd, table_ref, &hton_can_recreate))
DBUG_RETURN(TRUE);
@ -525,12 +531,6 @@ bool Truncate_statement::execute(THD *thd)
if (check_one_table_access(thd, DROP_ACL, first_table))
DBUG_RETURN(res);
#ifdef WITH_WSREP
if (WSREP(thd) && wsrep_to_isolation_begin(thd,
first_table->db,
first_table->table_name, NULL))
DBUG_RETURN(TRUE);
#endif /* WITH_WSREP */
if (! (res= truncate_table(thd, first_table)))
my_ok(thd);
DBUG_RETURN(res);

View file

@ -166,6 +166,7 @@ static int wsrep_write_cache_once(wsrep_t* const wsrep,
{
WSREP_WARN("transaction size limit (%lu) exceeded: %zu",
wsrep_max_ws_size, total_length);
err = WSREP_TRX_SIZE_EXCEEDED;
goto cleanup;
}
@ -177,7 +178,7 @@ static int wsrep_write_cache_once(wsrep_t* const wsrep,
{
WSREP_ERROR("could not (re)allocate buffer: %zu + %u",
allocated, length);
err = WSREP_SIZE_EXCEEDED;
err = WSREP_TRX_SIZE_EXCEEDED;
goto cleanup;
}
@ -232,7 +233,7 @@ static int wsrep_write_cache_inc(wsrep_t* const wsrep,
if (reinit_io_cache(cache, READ_CACHE, 0, 0, 0))
{
WSREP_ERROR("failed to initialize io-cache");
return WSREP_TRX_ROLLBACK;
return WSREP_TRX_ERROR;
}
int err(WSREP_OK);
@ -253,7 +254,7 @@ static int wsrep_write_cache_inc(wsrep_t* const wsrep,
{
WSREP_WARN("transaction size limit (%lu) exceeded: %zu",
wsrep_max_ws_size, total_length);
err = WSREP_SIZE_EXCEEDED;
err = WSREP_TRX_SIZE_EXCEEDED;
goto cleanup;
}

View file

@ -303,19 +303,6 @@ check_opts (int const argc, const char* const argv[], struct opt opts[])
}
}
long long query_cache_size, query_cache_type;
if ((err = get_long_long (opts[QUERY_CACHE_SIZE], &query_cache_size, 10)))
return err;
if ((err = get_long_long (opts[QUERY_CACHE_TYPE], &query_cache_type, 10)))
return err;
if (0 != query_cache_size && 0 != query_cache_type)
{
WSREP_ERROR ("Query cache is not supported (size=%lld type=%lld)",
query_cache_size, query_cache_type);
rcode = EINVAL;
}
bool locked_in_memory;
err = get_bool (opts[LOCKED_IN_MEMORY], &locked_in_memory);
if (err) { WSREP_ERROR("get_bool error: %s", strerror(err)); return err; }

View file

@ -139,7 +139,7 @@ wsrep_close_connection(handlerton* hton, THD* thd)
- certification test or an equivalent. As a result,
the current transaction just rolls back
Error codes:
WSREP_TRX_ROLLBACK, WSREP_TRX_ERROR
WSREP_TRX_CERT_FAIL, WSREP_TRX_SIZE_EXCEEDED, WSREP_TRX_ERROR
- a post-certification failure makes this server unable to
commit its own WS and therefore the server must abort
*/
@ -160,14 +160,7 @@ static int wsrep_prepare(handlerton *hton, THD *thd, bool all)
!thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) &&
(thd->variables.wsrep_on && !wsrep_trans_cache_is_empty(thd)))
{
switch (wsrep_run_wsrep_commit(thd, hton, all))
{
case WSREP_TRX_OK:
break;
case WSREP_TRX_ROLLBACK:
case WSREP_TRX_ERROR:
DBUG_RETURN(1);
}
DBUG_RETURN (wsrep_run_wsrep_commit(thd, hton, all));
}
DBUG_RETURN(0);
}
@ -324,7 +317,7 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all)
WSREP_INFO("innobase_commit, abort %s",
(thd->query()) ? thd->query() : "void");
}
DBUG_RETURN(WSREP_TRX_ROLLBACK);
DBUG_RETURN(WSREP_TRX_CERT_FAIL);
}
mysql_mutex_lock(&LOCK_wsrep_replaying);
@ -375,7 +368,7 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all)
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
WSREP_DEBUG("innobase_commit abort after replaying wait %s",
(thd->query()) ? thd->query() : "void");
DBUG_RETURN(WSREP_TRX_ROLLBACK);
DBUG_RETURN(WSREP_TRX_CERT_FAIL);
}
thd->wsrep_query_state = QUERY_COMMITTING;
@ -388,7 +381,7 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all)
rcode = wsrep_write_cache(wsrep, thd, cache, &data_len);
if (WSREP_OK != rcode) {
WSREP_ERROR("rbr write fail, data_len: %zu, %d", data_len, rcode);
DBUG_RETURN(WSREP_TRX_ROLLBACK);
DBUG_RETURN(WSREP_TRX_SIZE_EXCEEDED);
}
}
@ -510,7 +503,7 @@ wsrep_run_wsrep_commit(THD *thd, handlerton *hton, bool all)
}
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
DBUG_RETURN(WSREP_TRX_ROLLBACK);
DBUG_RETURN(WSREP_TRX_CERT_FAIL);
case WSREP_CONN_FAIL:
WSREP_ERROR("connection failure");

View file

@ -126,7 +126,7 @@ static void wsrep_log_cb(wsrep_log_level_t level, const char *msg) {
sql_print_error("WSREP: %s", msg);
break;
case WSREP_LOG_DEBUG:
if (wsrep_debug) sql_print_information ("[Debug] WSREP: %s", msg);
sql_print_information ("[Debug] WSREP: %s", msg);
default:
break;
}

View file

@ -232,8 +232,9 @@ extern void wsrep_ready_wait();
enum wsrep_trx_status {
WSREP_TRX_OK,
WSREP_TRX_ROLLBACK,
WSREP_TRX_ERROR,
WSREP_TRX_CERT_FAIL, /* certification failure, must abort */
WSREP_TRX_SIZE_EXCEEDED, /* trx size exceeded */
WSREP_TRX_ERROR, /* native mysql error */
};
extern enum wsrep_trx_status
@ -269,7 +270,7 @@ extern mysql_mutex_t LOCK_wsrep_desync;
extern wsrep_aborting_thd_t wsrep_aborting_thd;
extern my_bool wsrep_emulate_bin_log;
extern int wsrep_to_isolation;
#ifdef HAVE_PSI_INTERFACE
extern PSI_mutex_key key_LOCK_wsrep_ready;
extern PSI_mutex_key key_COND_wsrep_ready;
extern PSI_mutex_key key_LOCK_wsrep_sst;
@ -284,7 +285,7 @@ extern PSI_mutex_key key_LOCK_wsrep_replaying;
extern PSI_cond_key key_COND_wsrep_replaying;
extern PSI_mutex_key key_LOCK_wsrep_slave_threads;
extern PSI_mutex_key key_LOCK_wsrep_desync;
#endif /* HAVE_PSI_INTERFACE */
struct TABLE_LIST;
int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,
const TABLE_LIST* table_list);

View file

@ -5665,7 +5665,9 @@ ha_innobase::write_row(
|| sql_command == SQLCOM_CREATE_INDEX
#ifdef WITH_WSREP
|| (wsrep_on(user_thd) && wsrep_load_data_splitting &&
sql_command == SQLCOM_LOAD)
sql_command == SQLCOM_LOAD &&
!thd_test_options(
user_thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
#endif /* WITH_WSREP */
|| sql_command == SQLCOM_DROP_INDEX)
&& num_write_row >= 10000) {
@ -5713,7 +5715,8 @@ no_commit:
{
case WSREP_TRX_OK:
break;
case WSREP_TRX_ROLLBACK:
case WSREP_TRX_SIZE_EXCEEDED:
case WSREP_TRX_CERT_FAIL:
case WSREP_TRX_ERROR:
DBUG_RETURN(1);
}
@ -5737,7 +5740,8 @@ no_commit:
{
case WSREP_TRX_OK:
break;
case WSREP_TRX_ROLLBACK:
case WSREP_TRX_SIZE_EXCEEDED:
case WSREP_TRX_CERT_FAIL:
case WSREP_TRX_ERROR:
DBUG_RETURN(1);
}
@ -7478,9 +7482,6 @@ ha_innobase::wsrep_append_keys(
dict_table_get_referenced_constraint(tab, idx)) ||
(!tab && referenced_by_foreign_key()))) {
if (key_info->flags & HA_NOSAME || shared)
key_appended = true;
len = wsrep_store_key_val_for_row(
table, i, key0, key_info->key_length,
record0, &is_null);
@ -7489,6 +7490,9 @@ ha_innobase::wsrep_append_keys(
thd, trx, table_share, table,
keyval0, len+1, shared);
if (rcode) DBUG_RETURN(rcode);
if (key_info->flags & HA_NOSAME || shared)
key_appended = true;
}
else
{

View file

@ -1757,6 +1757,10 @@ row_ins_scan_sec_index_for_duplicate(
lock_type, block, rec, index, offsets, thr);
} else {
#ifdef WITH_WSREP
/* appliers don't need dupkey checks */
if (!wsrep_thd_is_BF(thr_get_trx(thr)->mysql_thd, 0))
#endif /* WITH_WSREP */
err = row_ins_set_shared_rec_lock(
lock_type, block, rec, index, offsets, thr);
}

View file

@ -6629,7 +6629,9 @@ ha_innobase::write_row(
|| sql_command == SQLCOM_CREATE_INDEX
#ifdef WITH_WSREP
|| (wsrep_on(user_thd) && wsrep_load_data_splitting &&
sql_command == SQLCOM_LOAD)
sql_command == SQLCOM_LOAD &&
!thd_test_options(
user_thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))
#endif /* WITH_WSREP */
|| sql_command == SQLCOM_DROP_INDEX)
&& num_write_row >= 10000) {
@ -6677,7 +6679,8 @@ no_commit:
{
case WSREP_TRX_OK:
break;
case WSREP_TRX_ROLLBACK:
case WSREP_TRX_SIZE_EXCEEDED:
case WSREP_TRX_CERT_FAIL:
case WSREP_TRX_ERROR:
DBUG_RETURN(1);
}
@ -6701,7 +6704,8 @@ no_commit:
{
case WSREP_TRX_OK:
break;
case WSREP_TRX_ROLLBACK:
case WSREP_TRX_SIZE_EXCEEDED:
case WSREP_TRX_CERT_FAIL:
case WSREP_TRX_ERROR:
DBUG_RETURN(1);
}
@ -8521,9 +8525,6 @@ ha_innobase::wsrep_append_keys(
dict_table_get_referenced_constraint(tab, idx)) ||
(!tab && referenced_by_foreign_key()))) {
if (key_info->flags & HA_NOSAME || shared)
key_appended = true;
len = wsrep_store_key_val_for_row(
table, i, key0, key_info->key_length,
record0, &is_null);
@ -8532,6 +8533,9 @@ ha_innobase::wsrep_append_keys(
thd, trx, table_share, table,
keyval0, len+1, shared);
if (rcode) DBUG_RETURN(rcode);
if (key_info->flags & HA_NOSAME || shared)
key_appended = true;
}
else
{

View file

@ -1769,6 +1769,10 @@ row_ins_scan_sec_index_for_duplicate(
lock_type, block, rec, index, offsets, thr);
} else {
#ifdef WITH_WSREP
/* appliers don't need dupkey checks */
if (!wsrep_thd_is_BF(thr_get_trx(thr)->mysql_thd, 0))
#endif /* WITH_WSREP */
err = row_ins_set_shared_rec_lock(
lock_type, block, rec, index, offsets, thr);
}