一个主题有 3 个副本,min.insyinc.replicas 到 2 个,当跟随者和同步副本都宕机并且消费者想要阅读时会发生什么?

A topic has 3 replicas and min.insyinc.replicas to 2, what happens when both the follower and in-syinc replica go down and the consumer wants to read?

我正在准备CCDAK认证,我踏入了这个问题:

"A topic has three replicas and you set min.insync.replicas to 2. If two out of three replicas are not available, what happens when a consume request is sent to broker?"

给出的答案是:

Data will be returned by the remaining in-sync replica

我对一个极端情况有疑问:当领导者和同步副本同时(第三个副本仍然不同步)时会发生什么) 并且消费者想要读取第三个副本中不存在的消息(它可能尚未复制,因为它不是同步副本)?

一个实际的例子是这样的:假设消费者已经提交了偏移量 10 并想从 11 读取,但是第三个副本有消息到偏移量 9。领导者和追随者都宕机了,会发生什么?消费者会只是等待其他经纪人,还是 Kafka 会抛出一个我必须处理的错误?

您的消费者不会重新平衡,因为从 Kafka 方面来看,它不能 select 该分区的领导者。该分区未同步,然后 Kafka 将等待其他副本启动到 select 领导者。在这种情况下,您的消费者将挂起。