如下场景:
1,
master
gtid_executed uuid:1
gtid_owned uuid:2-3
2,
slave
gtid_executed uuid:1-2
停止从机io thread,uuid:2事务未返回ack
3,
启动从机器 io thread后,会接收主机uuid:3binlog,并且返回此事务的uuid
此时2-3事务在主机上的表现
4,
测试结果为:
2-3事务均提交。
5,
证明ack receiver线上应该判断的是need <= received
代码如下。
控制函数ReplSemiSyncMaster::commitTrx
while (is_on())
{
if (reply_file_name_inited_)
{
int cmp = ActiveTranx::compare(reply_file_name_, reply_file_pos_,
trx_wait_binlog_name, trx_wait_binlog_pos);
if (cmp >= 0)
{
/* We have already sent the relevant binlog to the slave: no need to
* wait here.
*/
if (trace_level_ & kTraceDetail)
sql_print_information("%s: Binlog reply is ahead (%s, %lu),",
kWho, reply_file_name_, (unsigned long)reply_file_pos_);
break;
}
}
......
}
compare如下
int ActiveTranx::compare(const char *log_file_name1, my_off_t log_file_pos1,
const char *log_file_name2, my_off_t log_file_pos2)
{
int cmp = strcmp(log_file_name1, log_file_name2);
if (cmp != 0)
return cmp;
if (log_file_pos1 > log_file_pos2)
return 1;
else if (log_file_pos1 < log_file_pos2)
return -1;
return 0;
}
所以实验结果并不意外。