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