本文介绍了在具有J = 1和W = Majority的MongoDB副本集上是否仍会发生回滚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读文档,据我了解,我看到了仍然可能发生回滚的情况:

I have been reading the docs and from my understanding I could see a scenario whereby a rollback could still occur:

  • 写入转到主目录,以确认日志已被写入磁盘
  • 大多数辅助副本可确认已写入,但不写入磁盘
  • 整个群集的电源故障
  • 由于某种原因,主电源在恢复电源后无法启动
  • 次要角色起主要作用
  • 原始的主要数据库终于开始,作为辅助数据库重新加入集合并回滚

这种情况合理吗?

推荐答案

如果其他成员获取命令并写入磁盘之间电源中断,这可能是回滚的可能情况.

This could be a plausible case for rollback yes, if the power fails between the other members getting the command and writing to disk.

如您所指出的,在这种情况下,主数据库无法启动,因此一旦备份,将包含其余集合无法验证导致回滚的操作.

In this case, as you point out, the primary could not start back up and so would, once back up, contain operations that the rest of the set could not validate causing a rollback.

还应注意,作为曲线球,如果主 不下降,则它将返回成功的写入操作,而应用程序则更明智地认为该设置已消失向下,并且它们的{w: majority}未写入磁盘.当然,这是一个边缘案例.

It is also good to note, as a curve ball that if the primary were not to go down then it would return a successful write and the application would be none the wiser that the set has gone down and their {w: majority} wasn't written to disk. This is, of course, an edge case.

这篇关于在具有J = 1和W = Majority的MongoDB副本集上是否仍会发生回滚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 14:03