The flags trx->active_commit_ordered and trx->active_prepare got cleared in
trx_init() during the fast part of commit (ie. commit_ordered()). This is
too early, then the values are lost when processing reaches
trx_commit_complete_for_mysql(). This caused the MDEV-232 optimization to be
omitted, adding an extra fsync() at the end of commit when using the legacy
binlog and causing severe performance regression.

The values of trx->active_commit_ordered and trx->active_prepare must
persist to the end of commit procesing, same as trx->is_registered. This is
done in this patch, active_commit_ordered and active_prepare are cleared in
trx_deregister_from_2pc() together with trx->is_registered in
trx_deregister_from_2pc(), and asserted to be cleared when
trx->is_registered is set for a following transaction.

Signed-off-by: Kristian Nielsen <[email protected]>
---
 storage/innobase/handler/ha_innodb.cc | 1 +
 storage/innobase/trx/trx0trx.cc       | 4 ----
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/storage/innobase/handler/ha_innodb.cc 
b/storage/innobase/handler/ha_innodb.cc
index 2b0bb2ca5f1..6e5271ef1e1 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -3005,6 +3005,7 @@ innobase_register_trx(
        trx_t*          trx)    /* in: transaction to register */
 {
   ut_ad(!trx->active_commit_ordered);
+  ut_ad(!trx->active_prepare);
   const trx_id_t trx_id= trx->id;
 
   trans_register_ha(thd, false, hton, trx_id);
diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc
index a6406971c8a..518f46ff5cd 100644
--- a/storage/innobase/trx/trx0trx.cc
+++ b/storage/innobase/trx/trx0trx.cc
@@ -113,10 +113,6 @@ trx_init(
 
        trx->op_info = "";
 
-       trx->active_commit_ordered = false;
-
-       trx->active_prepare = false;
-
        trx->isolation_level = TRX_ISO_REPEATABLE_READ;
 
        trx->check_foreigns = true;
-- 
2.47.3

_______________________________________________
commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to