这是一个stage,定义在mysqld.cc文件的11321行。
mysql在sql/rpl_mts_submode.cc文件的wait_for_last_committed_trx方法中进入此stage。
#rpl_mts_submode.cc
bool Mts_submode_logical_clock::wait_for_last_committed_trx(
Relay_log_info *rli, longlong last_committed_arg) {
THD *thd = rli->info_thd;
DBUG_TRACE;
if (last_committed_arg == SEQ_UNINIT) return false;
mysql_mutex_lock(&rli->mts_gaq_LOCK);
DBUG_ASSERT(min_waited_timestamp == SEQ_UNINIT);
min_waited_timestamp.store(last_committed_arg);
/*
This transaction is a candidate for insertion into the waiting list.
That fact is descibed by incrementing waited_timestamp_cnt.
When the candidate won't make it the counter is decremented at once
while the mutex is hold.
*/
if ((!rli->info_thd->killed && !is_error) &&
!clock_leq(last_committed_arg, get_lwm_timestamp(rli, true))) {
PSI_stage_info old_stage;
struct timespec ts[2];
set_timespec_nsec(&ts[0], 0);
DBUG_ASSERT(rli->gaq->len >= 2); // there's someone to wait
thd->ENTER_COND(&rli->logical_clock_cond, &rli->mts_gaq_LOCK,
&stage_worker_waiting_for_commit_parent, &old_stage);
do {
mysql_cond_wait(&rli->logical_clock_cond, &rli->mts_gaq_LOCK);
} while ((!rli->info_thd->killed && !is_error) &&
!clock_leq(last_committed_arg, estimate_lwm_timestamp()));
min_waited_timestamp.store(SEQ_UNINIT); // reset waiting flag
mysql_mutex_unlock(&rli->mts_gaq_LOCK);
thd->EXIT_COND(&old_stage);
set_timespec_nsec(&ts[1], 0);
rli->mts_total_wait_overlap += diff_timespec(&ts[1], &ts[0]);
} else {
min_waited_timestamp.store(SEQ_UNINIT);
mysql_mutex_unlock(&rli->mts_gaq_LOCK);
}
return rli->info_thd->killed || is_error;
}
bool Mts_submode_logical_clock::wait_for_last_committed_trx( Relay_log_info *rli, longlong last_committed_arg)方法由Mts_submode_logical_clock::schedule_next_event(Relay_log_info *rli, Log_event *ev