此命令阻塞当前客户端,直到所有以前的写命令都成功的传输和指定的slaves确认。如果超时,指定以毫秒为单位,即使指定的slaves还没有到达,命令任然返回。

命令始终返回之前写命令发送的slaves的数量,无论是在指定slaves的情况还是达到超时。

注意点:

  1. 当’WAIT’返回时,所有之前的写命令保证接收由WAIT返回的slaves的数量。
  2. 如果命令呗当做事务的一部分发送,该命令不阻塞,而是只尽快返回先前写命令的slaves的数量。
  3. 如果timeout是0那意味着永远阻塞。
  4. 由于WAIT返回的是在失败和成功的情况下的slaves的数量。客户端应该检查返回的slaves的数量是等于或更大的复制水平。

一致性(Consistency and WAIT)

Note that WAIT does not make Redis a strongly consistent store: while synchronous replication is part of a replicated state machine, it is not the only thing needed. However in the context of Sentinel or Redis Cluster failover, WAITimproves the real world data safety.

Specifically if a given write is transferred to one or more slaves, it is more likely (but not guaranteed) that if the master fails, we’ll be able to promote, during a failover, a slave that received the write: both Sentinel and Redis Cluster will do a best-effort attempt to promote the best slave among the set of available slaves.

However this is just a best-effort attempt so it is possible to still lose a write synchronously replicated to multiple slaves.

Implementation details

Since the introduction of partial resynchronization with slaves (PSYNC feature) Redis slaves asynchronously ping their master with the offset they already processed in the replication stream. This is used in multiple ways:

  1. Detect timed out slaves.
  2. Perform a partial resynchronization after a disconnection.
  3. Implement WAIT.

In the specific case of the implementation of WAIT, Redis remembers, for each client, the replication offset of the produced replication stream when a given write command was executed in the context of a given client. When WAIT is called Redis checks if the specified number of slaves already acknowledged this offset or a greater one.

@return

@integer-reply: The command returns the number of slaves reached by all the writes performed in the context of the current connection.

@examples

> SET foo bar
OK
> WAIT 1 0
(integer) 1
> WAIT 2 1000
(integer) 1

In the following example the first call to WAIT does not use a timeout and asks for the write to reach 1 slave. It returns with success. In the second attempt instead we put a timeout, and ask for the replication of the write to two slaves. Since there is a single slave available, after one second WAIT unblocks and returns 1, the number of slaves reached.

本文作者:陈群
本文来自云栖社区合作伙伴rediscn,了解相关信息可以关注redis.cn网站。

WAIT numslaves timeout相关推荐

  1. redis 集群 实操 (史上最全、5w字长文)

    文章很长,建议收藏起来慢慢读! 总目录 博客园版 为大家准备了更多的好文章!!!! 推荐:尼恩Java面试宝典(持续更新 + 史上最全 + 面试必备)具体详情,请点击此链接 尼恩Java面试宝典,34 ...

  2. redis cluster 集群 HA 原理和实操(史上最全、面试必备)

    文章很长,建议收藏起来慢慢读!疯狂创客圈总目录 语雀版 | 总目录 码云版| 总目录 博客园版 为您奉上珍贵的学习资源 : 免费赠送 经典图书:<Java高并发核心编程(卷1)> 面试必备 ...

  3. Redis 数据类型与使用命令大全以及Java使用

    基础数据类型 具体详情可直接访问Redis官网,这里只做命令总结 String 二进制安全的字符串 Lists: 按插入顺序排序的字符串元素的集合.他们基本上就是链表(linked lists). S ...

  4. linux请求超时 ping_网站 ping 超时

    ping命令诊断网络故障 ping命令诊断网络故障 ping(Packet Internet Grope),因特网包探索器,用于测试网络连接量的程序.ping发送一个ICMP回声请求消息给目的地并报告 ...

  5. Android开发遇到eclipse运行程序时报timeout

    运行的时候总是提示这样 Failed to install ***.apk on device 'emulator-5554': timeout Launch canceled! 第一次遇到这样的问题 ...

  6. Python中线程Timeout的使用

    Python中关于Timeout有另一种用起来更简便的方法,即使用装饰器.这种方式是使用sys模块的settrace等方法重构了python的threading类: #!/usr/bin/python ...

  7. 开发板tftp:timeout问题

    想要从PC上面tftp文件的时候遇到了tftp:timeout的问题: >: tftp -gr gprsapp 192.168.1.38 tftp: timeout 检查了网络,可以ping的通 ...

  8. 爬虫之requests模块超时参数timeout的使用

    爬虫之requests模块超时参数timeout的使用 在平时网上冲浪的过程中,我们经常会遇到网络波动,这个时候,一个请求等了很久可能任然没有结果. 在爬虫中,一个请求很久没有结果,就会让整个项目的效 ...

  9. GO库安装报错解决:unrecognized import path golang.org/x/net (https fetch: dial tcp i/o timeout

    今天想用goquery时,报错说golang.org\x\net\html没安装. ..\github.com\andybalholm\cascadia\selector.go:9:2: cannot ...

  10. java.sql.SQLException: Lock wait timeout exceeded

    2019独角兽企业重金招聘Python工程师标准>>> 先说我我的解决方法:找到锁住的线程然后kill掉. mysql> kill thr_id; 下面简单分析一下到底应该ki ...

最新文章

  1. Base64编码问题( Convert.ToBase64String)问题
  2. 如何评估AI在医学影像识别中的应用效果?
  3. UVa 122 Trees on the level
  4. apache 虚拟主机详细配置:http.conf配置详解
  5. jsp 跳到servlet路径_请问如何从jsp中跳到servlet中?
  6. 谷歌 AI 的2019:日均2篇论文,纵横16大方向,一文汇集重要开源算法
  7. 稳定土厂拌设备控制系统-基本介绍(图)
  8. tensorflow版本1.11.0
  9. 华为魔术2手机拆机图解_荣耀Magic2手机内部做工如何?荣耀Magic2手机拆机
  10. 跨域将.net 工程嵌入别的系统页面中发生的js、ajax的拒绝访问的错误
  11. http 405原因
  12. MATLAB泰勒展开
  13. 2021东南亚跨境电商平台之马来西亚热门电商平台排名TOP10
  14. 使用spoon对java代码进行转换
  15. android自动夜间模式吗,Android夜间模式的实现方案
  16. realme发布最便宜5G手机,心生不忿的小米强调体验不好
  17. SSM实现邮箱验证功能
  18. 彻底掌握 Javascript(二十一)async 函数-曾亮-专题视频课程
  19. java四则运算程序_java实现四则运算程序
  20. 跨境电商业务拓展专用服务器,腾讯云海外轻量应用服务器

热门文章

  1. BZOJ3309 DZY Loves Math 【莫比乌斯反演】
  2. ROS中测试机器人里程计信息
  3. ADF文件数据结构解析和ADF文件读写
  4. 如何求最小三元组距离
  5. Bone Collector(hdoj--2602--01背包)
  6. jsp获取相对路径网址的方法 request.getContextPath()
  7. 主数据文件损坏(或丢失)情况下,如何备份尾部事务日志.
  8. golang格式化输出---fmt包用法详解
  9. fiddler 的AutoRespoder的使用(手动添加测试桩)
  10. 从内存分配分析程序初始化和存储