GitHub user greatsharp added a comment to the discussion: Kvrocks gracefully 
failover design proposal

因为是非正式的讨论,我就直接以中文描述,以更方便和准确的描述我的想法。

关于手动主从切换,一般是发生在主动运维场景,人是可以主观判断当前集群的负载的,比如我们会在写QPS低的时候进行。
通常情况下主从节点规格一致,从节点除了做主从同步外,基本没有其它负载,其sequence在主写QPS低的情况下,基本能与主节点保持一致。

所以我的想法是,在当前clusterx 
setnodes命令后附加一个额外的write_forbidden_duration参数,单位毫秒(默认值1000),命令格式如下:
cluster setnodes $all_nodes_info $version $force $write_forbidden_duration
当使用控制器来刷新拓扑或节点上执行命令刷新拓扑时,仅对于需要进行主从切换的分片,其下的所有节点都加上此write_forbidden_duration参数;其它不需要进行主从切换的分片,不加此参数。

当需要进行主从切换的分片其下的所有节点都收到write_forbidden_duration参数时,设置标志位,节点在此write_forbidden_duration时间段内,不能执行kCmdWrite写入类型的命令,向客户端返回TRYAGAIN错误。其它非写入类的命令不受影响。
不论主从都sleep(write_forbidden_duration)时长,以满足主从完成同步,sequence达到一致。

接下来sleep(write_forbidden_duration)结束后,再继续执行原本的Cluster::SetClusterNodes拓扑刷新逻辑。

GitHub link: 
https://github.com/apache/kvrocks/discussions/3218#discussioncomment-14833734

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to