1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

References: lp:1144911 - merged fix for prepared statement processing from upstream.

Merged fix is revision 3853 in lp:~codership/codership-mysql/5.5-23
This commit is contained in:
Seppo Jaakola
2013-03-05 00:01:20 +02:00
parent 4174f1a474
commit 972acdb164
2 changed files with 105 additions and 74 deletions

View File

@ -6052,36 +6052,15 @@ void mysql_init_multi_delete(LEX *lex)
}
#ifdef WITH_WSREP
static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
Parser_state *parser_state)
void wsrep_replay_transaction(THD *thd)
{
bool is_autocommit=
!thd->in_multi_stmt_transaction_mode() &&
thd->wsrep_conflict_state == NO_CONFLICT &&
!thd->wsrep_applier &&
wsrep_read_only_option(thd, thd->lex->query_tables);
do
{
if (thd->wsrep_conflict_state== RETRY_AUTOCOMMIT)
{
thd->wsrep_conflict_state= NO_CONFLICT;
}
mysql_parse(thd, rawbuf, length, parser_state);
if (WSREP(thd)) {
/* wsrep BF abort in query exec phase */
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
if (thd->wsrep_conflict_state == MUST_ABORT) {
wsrep_client_rollback(thd);
WSREP_DEBUG("abort in exec query state, avoiding autocommit");
}
/* checking if BF trx must be replayed */
if (thd->wsrep_conflict_state== MUST_REPLAY) {
if (thd->wsrep_exec_mode!= REPL_RECV) {
if (thd->stmt_da->is_sent) {
if (thd->wsrep_conflict_state== MUST_REPLAY)
{
if (thd->wsrep_exec_mode!= REPL_RECV)
{
if (thd->stmt_da->is_sent)
{
WSREP_ERROR("replay issue, thd has reported status already");
}
thd->stmt_da->reset_diagnostics_area();
@ -6117,7 +6096,8 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
switch (rcode) {
switch (rcode)
{
case WSREP_OK:
thd->wsrep_conflict_state= NO_CONFLICT;
wsrep->post_commit(wsrep, &thd->wsrep_trx_handle);
@ -6125,7 +6105,8 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
thd->thread_id, (long long)thd->real_id);
break;
case WSREP_TRX_FAIL:
if (thd->stmt_da->is_sent) {
if (thd->stmt_da->is_sent)
{
WSREP_ERROR("replay failed, thd has reported status");
}
else
@ -6152,6 +6133,38 @@ static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
mysql_mutex_unlock(&LOCK_wsrep_replaying);
}
}
}
static void wsrep_mysql_parse(THD *thd, char *rawbuf, uint length,
Parser_state *parser_state)
{
bool is_autocommit=
!thd->in_multi_stmt_transaction_mode() &&
thd->wsrep_conflict_state == NO_CONFLICT &&
!thd->wsrep_applier &&
wsrep_read_only_option(thd, thd->lex->query_tables);
do
{
if (thd->wsrep_conflict_state== RETRY_AUTOCOMMIT)
{
thd->wsrep_conflict_state= NO_CONFLICT;
}
mysql_parse(thd, rawbuf, length, parser_state);
if (WSREP(thd)) {
/* wsrep BF abort in query exec phase */
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
if (thd->wsrep_conflict_state == MUST_ABORT) {
wsrep_client_rollback(thd);
WSREP_DEBUG("abort in exec query state, avoiding autocommit");
}
if (thd->wsrep_conflict_state== MUST_REPLAY)
{
wsrep_replay_transaction(thd);
}
/* setting error code for BF aborted trxs */
if (thd->wsrep_conflict_state == ABORTED ||

View File

@ -3483,7 +3483,9 @@ Prepared_statement::set_parameters(String *expanded_query,
return res;
}
#ifdef WITH_WSREP
void wsrep_replay_transaction(THD *thd);
#endif /* WITH_WSREP */
/**
Execute a prepared statement. Re-prepare it a limited number
of times if necessary.
@ -3563,6 +3565,22 @@ reexecute:
error= execute(expanded_query, open_cursor) || thd->is_error();
thd->m_reprepare_observer= NULL;
#ifdef WITH_WSREP
mysql_mutex_lock(&thd->LOCK_wsrep_thd);
switch (thd->wsrep_conflict_state)
{
case CERT_FAILURE:
WSREP_DEBUG("PS execute fail for CERT_FAILURE: thd: %ld err: %d",
thd->thread_id, thd->stmt_da->sql_errno() );
thd->wsrep_conflict_state = NO_CONFLICT;
break;
case MUST_REPLAY:
(void)wsrep_replay_transaction(thd);
default: break;
}
mysql_mutex_unlock(&thd->LOCK_wsrep_thd);
#endif /* WITH_WSREP */
if (error && !thd->is_fatal_error && !thd->killed &&
reprepare_observer.is_invalidated() &&