Commit 13a9bcc6 authored by sjaakola's avatar sjaakola Committed by Nirbhay Choubey

refs #11 #13 - skipping TOI, if all affected tables are temporary

parent 21bc3e3f
...@@ -1240,6 +1240,12 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len) ...@@ -1240,6 +1240,12 @@ create_view_query(THD *thd, uchar** buf, size_t* buf_len)
return wsrep_to_buf_helper(thd, buff.ptr(), buff.length(), buf, buf_len); return wsrep_to_buf_helper(thd, buff.ptr(), buff.length(), buf, buf_len);
} }
/*
returns:
0: statement was replicated as TOI
1: TOI replication was skipped
-1: TOI replication failed
*/
static int wsrep_TOI_begin(THD *thd, char *db_, char *table_, static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
const TABLE_LIST* table_list) const TABLE_LIST* table_list)
{ {
...@@ -1278,6 +1284,7 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_, ...@@ -1278,6 +1284,7 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
struct wsrep_buf buff = { buf, buf_len }; struct wsrep_buf buff = { buf, buf_len };
if (!buf_err && if (!buf_err &&
wsrep_prepare_keys_for_isolation(thd, db_, table_, table_list, &key_arr)&& wsrep_prepare_keys_for_isolation(thd, db_, table_, table_list, &key_arr)&&
key_arr.keys_len > 0 &&
WSREP_OK == (ret = wsrep->to_execute_start(wsrep, thd->thread_id, WSREP_OK == (ret = wsrep->to_execute_start(wsrep, thd->thread_id,
key_arr.keys, key_arr.keys_len, key_arr.keys, key_arr.keys_len,
&buff, 1, &buff, 1,
...@@ -1290,7 +1297,7 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_, ...@@ -1290,7 +1297,7 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
WSREP_DEBUG("TO BEGIN: %lld, %d",(long long)wsrep_thd_trx_seqno(thd), WSREP_DEBUG("TO BEGIN: %lld, %d",(long long)wsrep_thd_trx_seqno(thd),
thd->wsrep_exec_mode); thd->wsrep_exec_mode);
} }
else { else if (key_arr.keys_len > 0) {
/* jump to error handler in mysql_execute_command() */ /* jump to error handler in mysql_execute_command() */
WSREP_WARN("TO isolation failed for: %d, sql: %s. Check wsrep " WSREP_WARN("TO isolation failed for: %d, sql: %s. Check wsrep "
"connection state and retry the query.", "connection state and retry the query.",
...@@ -1301,6 +1308,13 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_, ...@@ -1301,6 +1308,13 @@ static int wsrep_TOI_begin(THD *thd, char *db_, char *table_,
wsrep_keys_free(&key_arr); wsrep_keys_free(&key_arr);
return -1; return -1;
} }
else {
/* non replicated DDL, affecting temporary tables only */
WSREP_DEBUG("TO isolation skipped for: %d, sql: %s."
"Only temporary tables affected.",
ret, (thd->query()) ? thd->query() : "void");
return 1;
}
return 0; return 0;
} }
...@@ -1454,9 +1468,15 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_, ...@@ -1454,9 +1468,15 @@ int wsrep_to_isolation_begin(THD *thd, char *db_, char *table_,
table_list); break; table_list); break;
case WSREP_OSU_RSU: ret = wsrep_RSU_begin(thd, db_, table_); break; case WSREP_OSU_RSU: ret = wsrep_RSU_begin(thd, db_, table_); break;
} }
if (!ret) switch (ret) {
{ case 0: thd->wsrep_exec_mode= TOTAL_ORDER; break;
thd->wsrep_exec_mode= TOTAL_ORDER; case 1:
/* TOI replication skipped, treat as success */
ret = 0;
break;
case -1:
/* TOI replication failed, treat as error */
break;
} }
} }
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment