diff options
author | Teemu Ollakka <teemu.ollakka@galeracluster.com> | 2017-12-17 14:41:55 +0200 |
---|---|---|
committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2018-04-24 13:42:05 +0300 |
commit | c2c61bbccea3525e12d8897c009898138a335392 (patch) | |
tree | e324065d3b0aaeee6026f9949d88ce3f2a2f126f /sql/wsrep_hton.cc | |
parent | a5001a2ad7fa664d17829cec2aa38867613df4d5 (diff) | |
download | mariadb-git-c2c61bbccea3525e12d8897c009898138a335392.tar.gz |
Provider rollback for ineffective trx
codership/mysql-wsrep#318 Adapt MTR tests to new Galera status variables
and fix exposed leaks
In certain cases it is possible that transaction has populated
keys in the provider but during commit time the IO cache is
empty, so the provider commit does not happen (for example
early ROLLBACK TO SAVEPOINT followed by COMMIT). Run
provider post_rollback() to clean up the transaction object.
Diffstat (limited to 'sql/wsrep_hton.cc')
-rw-r--r-- | sql/wsrep_hton.cc | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/sql/wsrep_hton.cc b/sql/wsrep_hton.cc index 0572230b18b..c18c179a4bd 100644 --- a/sql/wsrep_hton.cc +++ b/sql/wsrep_hton.cc @@ -99,16 +99,45 @@ void wsrep_register_hton(THD* thd, bool all) */ void wsrep_post_commit(THD* thd, bool all) { - if (thd->wsrep_exec_mode == LOCAL_COMMIT) + if (!WSREP(thd)) return; + + switch (thd->wsrep_exec_mode) { - DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno != WSREP_SEQNO_UNDEFINED); - if (wsrep->post_commit(wsrep, &thd->wsrep_ws_handle)) + case LOCAL_COMMIT: { + DBUG_ASSERT(thd->wsrep_trx_meta.gtid.seqno != WSREP_SEQNO_UNDEFINED); + if (wsrep->post_commit(wsrep, &thd->wsrep_ws_handle)) + { DBUG_PRINT("wsrep", ("set committed fail")); - WSREP_WARN("set committed fail: %llu %d", + WSREP_WARN("set committed fail: %llu %d", (long long)thd->real_id, thd->stmt_da->status()); + } + wsrep_cleanup_transaction(thd); + break; } - wsrep_cleanup_transaction(thd); + case LOCAL_STATE: + { + /* non-InnoDB statements may have populated events in stmt cache + => cleanup + */ + WSREP_DEBUG("cleanup transaction for LOCAL_STATE"); + /* + Run post-rollback hook to clean up in the case if + some keys were populated for the transaction in provider + but during commit time there was no write set to replicate. + This may happen when client sets the SAVEPOINT and immediately + rolls back to savepoint after first operation. + */ + if (all && thd->wsrep_conflict_state != MUST_REPLAY && + wsrep->post_rollback(wsrep, &thd->wsrep_ws_handle)) + { + WSREP_WARN("post_rollback fail: %llu %d", + (long long)thd->thread_id, thd->stmt_da->status()); + } + wsrep_cleanup_transaction(thd); + break; + } + default: break; } } |