MySQL5.7之前的版本半同步复制rpl_semi_sync_master_wait_point默认值为after_commit

MySQL5.7 半同步复制 rpl_semi_sync_master_wait_point默认值为after_sync

看一下官方文档怎么说


AFTER_SYNC (the default): The master writes each transaction to its binary log and the slave, and syncs the binary log to disk. The master waits for slave acknowledgment of transaction receipt after the sync. Upon receiving acknowledgment, the master commits the transaction to the storage engine and returns a result to the client, which then can proceed.

AFTER_COMMIT : The master writes each transaction to its binary log and the slave, syncs the binary log, and commits the transaction to the storage engine. The master waits for slave acknowledgment of transaction receipt after the commit. Upon receiving acknowledgment, the master returns a result to the client, which then can proceed.

For older versions of MySQL, semisynchronous master behavior is equivalent to a setting of AFTER_COMMIT.

The replication characteristics of these settings differ as follows:

With AFTER_SYNC, all clients see the committed transaction at the same time: After it has been acknowledged by the slave and committed to the storage engine on the master. Thus, all clients see the same data on the master.

In the event of master failure, all transactions committed on the master have been replicated to the slave (saved to its relay log). A crash of the master and failover to the slave is lossless because the slave is up to date.

With AFTER_COMMIT, the client issuing the transaction gets a return status only after the server commits to the storage engine and receives slave acknowledgment. After the commit and before slave acknowledgment, other clients can see the committed transaction before the committing client.



AFTER_SYNC (默认值):主服务器将每个事务写入其二进制日志和从服务器,并将二进制日志同步到磁盘。 在同步之后,主服务器等待从服务器确认接收的事务。 在接收到确认之后,主服务器将事务提交给存储引擎,并将结果返回给客户机,然后客户机就可以继续执行。

AFTER_COMMIT :主服务器将每个事务写入其二进制日志,从服务器同步二进制日志,并将事务提交到存储引擎。 在提交之后,主服务器等待从服务器对事务接收的确认。 在接收到确认之后,主程序将结果返回给客户端,然后客户端可以继续进行操作。

对于旧版本的MySQL,半同步主行为相当于设置AFTER_COMMIT。

这些设置的复制特征不同如下:

使用 AFTER_SYNC,所有客户端同时看到提交的事务:在从服务器确认并提交到主服务器上的存储引擎之后。 因此,所有客户端在主服务器上看到相同的数据。

在主服务器失败的情况下,在主服务器上提交的所有事务都被复制到从服务器(保存到它的中继日志中)。 主服务器的崩溃和到从服务器的故障转移是无损的,因为从服务器是最新的。

使用 AFTER_COMMIT,发出事务的客户端只有在服务器提交到存储引擎并收到从服务器的确认之后才会获得返回状态。 在提交之后和从确认之前,其他客户端可以在提交客户端之前看到提交的事务。