Commit 10727b69 authored by Marko Mäkelä's avatar Marko Mäkelä

Always initialize trx_t::start_time_micro

This affects the function has_higher_priority() for internal or
recovered transactions.
parent 10ee1b95
...@@ -867,10 +867,11 @@ struct trx_t{ ...@@ -867,10 +867,11 @@ struct trx_t{
when trx->in_rw_trx_list. Initially when trx->in_rw_trx_list. Initially
set to TRX_ID_MAX. */ set to TRX_ID_MAX. */
time_t start_time; /*!< time the trx state last time became /** wall-clock time of the latest transition to TRX_STATE_ACTIVE;
TRX_STATE_ACTIVE */ used for diagnostic purposes only */
ib_uint64_t start_time_micro; /*!< start time of transaction in time_t start_time;
microseconds */ /** microsecond_interval_timer() of transaction start */
ulonglong start_time_micro;
trx_id_t id; /*!< transaction id */ trx_id_t id; /*!< transaction id */
XID xid; /*!< X/Open XA transaction XID xid; /*!< X/Open XA transaction
identification to identify a identification to identify a
......
...@@ -2279,10 +2279,7 @@ If neither of them is wait lock, the first one has higher priority. ...@@ -2279,10 +2279,7 @@ If neither of them is wait lock, the first one has higher priority.
If only one of them is a wait lock, it has lower priority. If only one of them is a wait lock, it has lower priority.
Otherwise, the one with an older transaction has higher priority. Otherwise, the one with an older transaction has higher priority.
@returns true if lock1 has higher priority, false otherwise. */ @returns true if lock1 has higher priority, false otherwise. */
bool static bool has_higher_priority(lock_t *lock1, lock_t *lock2)
has_higher_priority(
lock_t *lock1,
lock_t *lock2)
{ {
if (lock1 == NULL) { if (lock1 == NULL) {
return false; return false;
......
...@@ -146,7 +146,8 @@ trx_purge_sys_create( ...@@ -146,7 +146,8 @@ trx_purge_sys_create(
here only because the query threads code requires it. It is otherwise here only because the query threads code requires it. It is otherwise
quite unnecessary. We should get rid of it eventually. */ quite unnecessary. We should get rid of it eventually. */
purge_sys->trx->id = 0; purge_sys->trx->id = 0;
purge_sys->trx->start_time = ut_time(); purge_sys->trx->start_time = time(NULL);
purge_sys->trx->start_time_micro = microsecond_interval_timer();
purge_sys->trx->state = TRX_STATE_ACTIVE; purge_sys->trx->state = TRX_STATE_ACTIVE;
purge_sys->trx->op_info = "purge trx"; purge_sys->trx->op_info = "purge trx";
......
...@@ -570,7 +570,8 @@ trx_resurrect_insert( ...@@ -570,7 +570,8 @@ trx_resurrect_insert(
/* trx_start_low() is not called with resurrect, so need to initialize /* trx_start_low() is not called with resurrect, so need to initialize
start time here.*/ start time here.*/
if (trx->state != TRX_STATE_COMMITTED_IN_MEMORY) { if (trx->state != TRX_STATE_COMMITTED_IN_MEMORY) {
trx->start_time = ut_time(); trx->start_time = time(NULL);
trx->start_time_micro = microsecond_interval_timer();
} }
if (undo->dict_operation) { if (undo->dict_operation) {
...@@ -656,7 +657,8 @@ trx_resurrect_update( ...@@ -656,7 +657,8 @@ trx_resurrect_update(
start time here.*/ start time here.*/
if (trx->state == TRX_STATE_ACTIVE if (trx->state == TRX_STATE_ACTIVE
|| trx->state == TRX_STATE_PREPARED) { || trx->state == TRX_STATE_PREPARED) {
trx->start_time = ut_time(); trx->start_time = time(NULL);
trx->start_time_micro = microsecond_interval_timer();
} }
if (undo->dict_operation) { if (undo->dict_operation) {
...@@ -907,8 +909,9 @@ trx_start_low( ...@@ -907,8 +909,9 @@ trx_start_low(
trx->start_time = ut_time(); trx->start_time = ut_time();
trx->start_time_micro = trx->start_time_micro = trx->mysql_thd
trx->mysql_thd ? thd_query_start_micro(trx->mysql_thd) : 0; ? thd_query_start_micro(trx->mysql_thd)
: microsecond_interval_timer();
MONITOR_INC(MONITOR_TRX_ACTIVE); MONITOR_INC(MONITOR_TRX_ACTIVE);
} }
......
...@@ -917,10 +917,11 @@ struct trx_t{ ...@@ -917,10 +917,11 @@ struct trx_t{
when trx->in_rw_trx_list. Initially when trx->in_rw_trx_list. Initially
set to TRX_ID_MAX. */ set to TRX_ID_MAX. */
time_t start_time; /*!< time the trx state last time became /** wall-clock time of the latest transition to TRX_STATE_ACTIVE;
TRX_STATE_ACTIVE */ used for diagnostic purposes only */
ib_uint64_t start_time_micro; /*!< start time of transaction in time_t start_time;
microseconds */ /** microsecond_interval_timer() of transaction start */
ulonglong start_time_micro;
trx_id_t id; /*!< transaction id */ trx_id_t id; /*!< transaction id */
XID xid; /*!< X/Open XA transaction XID xid; /*!< X/Open XA transaction
identification to identify a identification to identify a
......
...@@ -2077,10 +2077,7 @@ If neither of them is wait lock, the first one has higher priority. ...@@ -2077,10 +2077,7 @@ If neither of them is wait lock, the first one has higher priority.
If only one of them is a wait lock, it has lower priority. If only one of them is a wait lock, it has lower priority.
Otherwise, the one with an older transaction has higher priority. Otherwise, the one with an older transaction has higher priority.
@returns true if lock1 has higher priority, false otherwise. */ @returns true if lock1 has higher priority, false otherwise. */
bool static bool has_higher_priority(lock_t *lock1, lock_t *lock2)
has_higher_priority(
lock_t *lock1,
lock_t *lock2)
{ {
if (lock1 == NULL) { if (lock1 == NULL) {
return false; return false;
......
...@@ -146,7 +146,8 @@ trx_purge_sys_create( ...@@ -146,7 +146,8 @@ trx_purge_sys_create(
here only because the query threads code requires it. It is otherwise here only because the query threads code requires it. It is otherwise
quite unnecessary. We should get rid of it eventually. */ quite unnecessary. We should get rid of it eventually. */
purge_sys->trx->id = 0; purge_sys->trx->id = 0;
purge_sys->trx->start_time = ut_time(); purge_sys->trx->start_time = time(NULL);
purge_sys->trx->start_time_micro = microsecond_interval_timer();
purge_sys->trx->state = TRX_STATE_ACTIVE; purge_sys->trx->state = TRX_STATE_ACTIVE;
purge_sys->trx->op_info = "purge trx"; purge_sys->trx->op_info = "purge trx";
......
...@@ -749,7 +749,8 @@ trx_resurrect_insert( ...@@ -749,7 +749,8 @@ trx_resurrect_insert(
/* trx_start_low() is not called with resurrect, so need to initialize /* trx_start_low() is not called with resurrect, so need to initialize
start time here.*/ start time here.*/
if (trx->state != TRX_STATE_COMMITTED_IN_MEMORY) { if (trx->state != TRX_STATE_COMMITTED_IN_MEMORY) {
trx->start_time = ut_time(); trx->start_time = time(NULL);
trx->start_time_micro = microsecond_interval_timer();
} }
if (undo->dict_operation) { if (undo->dict_operation) {
...@@ -835,7 +836,8 @@ trx_resurrect_update( ...@@ -835,7 +836,8 @@ trx_resurrect_update(
start time here.*/ start time here.*/
if (trx->state == TRX_STATE_ACTIVE if (trx->state == TRX_STATE_ACTIVE
|| trx->state == TRX_STATE_PREPARED) { || trx->state == TRX_STATE_PREPARED) {
trx->start_time = ut_time(); trx->start_time = time(NULL);
trx->start_time_micro = microsecond_interval_timer();
} }
if (undo->dict_operation) { if (undo->dict_operation) {
...@@ -1106,8 +1108,9 @@ trx_start_low( ...@@ -1106,8 +1108,9 @@ trx_start_low(
trx->start_time = ut_time(); trx->start_time = ut_time();
trx->start_time_micro = trx->start_time_micro = trx->mysql_thd
trx->mysql_thd ? thd_query_start_micro(trx->mysql_thd) : 0; ? thd_query_start_micro(trx->mysql_thd)
: microsecond_interval_timer();
MONITOR_INC(MONITOR_TRX_ACTIVE); MONITOR_INC(MONITOR_TRX_ACTIVE);
} }
......
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