Commit 30d5e327 authored by Sunny Bains's avatar Sunny Bains

Bug #57243 Inconsistent use of trans_register_ha() API in InnoDB

Remove trx_t::active_trans. Split into two separate fields with distinct
responsibilities. trx_t::is_registered and trx_t::owns_prepare_mutex.
There are wrapper functions for using this fields in ha_innodb.cc. The
wrapper functions check for invariants.

Fix some formatting to conform to InnoDB guidelines.

Remove innobase_register_stmt() and innobase_register_trx_and_stmt().

Add:
trx_is_started()
trx_deregister_from_2pc()
trx_register_for_2pc()
trx_is_registered_for_2pc()
trx_owns_prepare_commit_mutex_set()
trx_has_prepare_commit_mutex()

rb://479, Approved by Jimmy Yang.
parent 7ee0551f
This diff is collapsed.
...@@ -470,6 +470,20 @@ struct trx_struct{ ...@@ -470,6 +470,20 @@ struct trx_struct{
of view of concurrency control: of view of concurrency control:
TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY, TRX_ACTIVE, TRX_COMMITTED_IN_MEMORY,
... */ ... */
/*------------------------------*/
/* MySQL has a transaction coordinator to coordinate two phase
commit between multiple storage engines and the binary log. When
an engine participates in a transaction, it's responsible for
registering itself using the trans_register_ha() API. */
unsigned is_registered:1;/* This flag is set to 1 after the
transaction has been registered with
the coordinator using the XA API, and
is set to 0 after commit or rollback. */
unsigned owns_prepare_mutex:1;/* 1 if owns prepare mutex, if
this is set to 1 then registered should
also be set to 1. This is used in the
XA code */
/*------------------------------*/
ulint isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */ ulint isolation_level;/* TRX_ISO_REPEATABLE_READ, ... */
ulint check_foreigns; /* normally TRUE, but if the user ulint check_foreigns; /* normally TRUE, but if the user
wants to suppress foreign key checks, wants to suppress foreign key checks,
...@@ -500,9 +514,6 @@ struct trx_struct{ ...@@ -500,9 +514,6 @@ struct trx_struct{
in that case we must flush the log in that case we must flush the log
in trx_commit_complete_for_mysql() */ in trx_commit_complete_for_mysql() */
ulint duplicates; /*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */ ulint duplicates; /*!< TRX_DUP_IGNORE | TRX_DUP_REPLACE */
ulint active_trans; /*!< 1 - if a transaction in MySQL
is active. 2 - if prepare_commit_mutex
was taken */
ulint has_search_latch; ulint has_search_latch;
/* TRUE if this trx has latched the /* TRUE if this trx has latched the
search system latch in S-mode */ search system latch in S-mode */
......
...@@ -105,7 +105,11 @@ trx_create( ...@@ -105,7 +105,11 @@ trx_create(
trx->is_purge = 0; trx->is_purge = 0;
trx->is_recovered = 0; trx->is_recovered = 0;
trx->conc_state = TRX_NOT_STARTED; trx->conc_state = TRX_NOT_STARTED;
trx->start_time = time(NULL);
trx->is_registered = 0;
trx->owns_prepare_mutex = 0;
trx->start_time = ut_time();
trx->isolation_level = TRX_ISO_REPEATABLE_READ; trx->isolation_level = TRX_ISO_REPEATABLE_READ;
...@@ -124,7 +128,6 @@ trx_create( ...@@ -124,7 +128,6 @@ trx_create(
trx->table_id = 0; trx->table_id = 0;
trx->mysql_thd = NULL; trx->mysql_thd = NULL;
trx->active_trans = 0;
trx->duplicates = 0; trx->duplicates = 0;
trx->n_mysql_tables_in_use = 0; trx->n_mysql_tables_in_use = 0;
......
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