Commit 6fa42d1a authored by Kristian Nielsen's avatar Kristian Nielsen

MDEV-34705: Binlog in Engine

Skip prepare step in InnoDB when it handles the binlog, but re-enable
InnoDB fsync at commit.
Signed-off-by: default avatarKristian Nielsen <knielsen@knielsen-hq.org>
parent 5147a680
...@@ -1913,6 +1913,10 @@ int ha_commit_trans(THD *thd, bool all) ...@@ -1913,6 +1913,10 @@ int ha_commit_trans(THD *thd, bool all)
*/ */
if (! hi->is_trx_read_write()) if (! hi->is_trx_read_write())
continue; continue;
/* We do not need to 2pc the binlog with the engine that implements it. */
/* ToDo: This needs refinement, at least to handle the case when we are not binlogging. And maybe the logic could happen more elegantly in a different place, higher in the call stack? */
if (ht == opt_binlog_engine_hton)
continue;
/* /*
Sic: we know that prepare() is not NULL since otherwise Sic: we know that prepare() is not NULL since otherwise
trans->no_2pc would have been set. trans->no_2pc would have been set.
......
...@@ -2857,6 +2857,7 @@ trx_deregister_from_2pc( ...@@ -2857,6 +2857,7 @@ trx_deregister_from_2pc(
{ {
trx->is_registered= false; trx->is_registered= false;
trx->active_commit_ordered= false; trx->active_commit_ordered= false;
trx->active_prepare= false;
} }
/*********************************************************************//** /*********************************************************************//**
...@@ -16969,6 +16970,7 @@ innobase_xa_prepare( ...@@ -16969,6 +16970,7 @@ innobase_xa_prepare(
ut_ad(trx_is_registered_for_2pc(trx)); ut_ad(trx_is_registered_for_2pc(trx));
trx_prepare_for_mysql(trx); trx_prepare_for_mysql(trx);
trx->active_prepare= true;
} else { } else {
/* We just mark the SQL statement ended and do not do a /* We just mark the SQL statement ended and do not do a
transaction prepare */ transaction prepare */
......
...@@ -807,7 +807,10 @@ struct trx_t : ilist_node<> ...@@ -807,7 +807,10 @@ struct trx_t : ilist_node<>
is set to false after commit or is set to false after commit or
rollback. */ rollback. */
/** whether this is holding the prepare mutex */ /** whether this is holding the prepare mutex */
/* ToDo: This need a better mechanism. It is currently done to know that we did not do a prepare step before commit_ordered, due to binlog being stored in InnoDB; and therefore we need to do an fsync of the log in commit to make the commit durable. */
bool active_commit_ordered; bool active_commit_ordered;
/** whether innobase_xa_prepare() was done. */
bool active_prepare;
/*------------------------------*/ /*------------------------------*/
bool flush_log_later;/* In 2PC, we hold the bool flush_log_later;/* In 2PC, we hold the
prepare_commit mutex across prepare_commit mutex across
......
...@@ -106,6 +106,8 @@ trx_init( ...@@ -106,6 +106,8 @@ trx_init(
trx->active_commit_ordered = false; trx->active_commit_ordered = false;
trx->active_prepare = false;
trx->isolation_level = TRX_ISO_REPEATABLE_READ; trx->isolation_level = TRX_ISO_REPEATABLE_READ;
trx->check_foreigns = true; trx->check_foreigns = true;
...@@ -418,6 +420,7 @@ void trx_t::free() ...@@ -418,6 +420,7 @@ void trx_t::free()
bulk_insert */); bulk_insert */);
MEM_NOACCESS(&is_registered, sizeof is_registered); MEM_NOACCESS(&is_registered, sizeof is_registered);
MEM_NOACCESS(&active_commit_ordered, sizeof active_commit_ordered); MEM_NOACCESS(&active_commit_ordered, sizeof active_commit_ordered);
MEM_NOACCESS(&active_prepare, sizeof active_prepare);
MEM_NOACCESS(&flush_log_later, sizeof flush_log_later); MEM_NOACCESS(&flush_log_later, sizeof flush_log_later);
MEM_NOACCESS(&duplicates, sizeof duplicates); MEM_NOACCESS(&duplicates, sizeof duplicates);
MEM_NOACCESS(&dict_operation, sizeof dict_operation); MEM_NOACCESS(&dict_operation, sizeof dict_operation);
...@@ -1749,7 +1752,7 @@ void trx_commit_complete_for_mysql(trx_t *trx) ...@@ -1749,7 +1752,7 @@ void trx_commit_complete_for_mysql(trx_t *trx)
case 0: case 0:
return; return;
case 1: case 1:
if (trx->active_commit_ordered) if (trx->active_commit_ordered && trx->active_prepare)
return; return;
} }
trx_flush_log_if_needed(lsn, trx); trx_flush_log_if_needed(lsn, trx);
......
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