GitHub user RongtongJin added a comment to the discussion: MessageStore writeable when HA switch
在角色切换时禁止写入这个方案之前也一直有考虑。当前没有这么做有以下几点 1.备切主ChangeToMaster - 先完成转换,最后再设置成主 - 备正常情况下不会有消息写入(先与master断开恢复完topicQueueTable,再变成主向nameserver注册对外提供服务) - 备不存在内部二级消息的转换 (从这里来说handleSlaveSynchronize(BrokerRole.SYNC_MASTER);和this.haService.changeToMaster(newMasterEpoch);两句代码调换顺序会更好) 2.主切备ChangeToSalve - 先设置成备、再完成转换(先停止二级消息转换流程,变成Slave(先保证不对外接收消息),再去完成后续连接建立等。) 当前主要依靠角色切换时操作的顺序来保证安全性,但如果无法保证(没有考虑全面),最后的手段可以是通过设置标志位禁写来强制保证安全,这个问题可以继续探讨。 而针对pr #6435 的问题,主切主,备切备的场景,除了解决topicQueueTable回退的问题,一些不必要的操作(比如连接的断开、二级消息任务不必要的起停)也可以避免,所以这个pr本身还是有必要的。 GitHub link: https://github.com/apache/rocketmq/discussions/6472#discussioncomment-5429607 ---- This is an automatically sent email for dev@rocketmq.apache.org. To unsubscribe, please send an email to: dev-unsubscr...@rocketmq.apache.org