Skip to Content
MongoDB权威指南(第3版)
book

MongoDB权威指南(第3版)

by Shannon Bradshaw, Eoin Brazil, Kristina Chodorow
November 2021
Intermediate to advanced
410 pages
12h 1m
Chinese
Posts & Telecom Press
Content preview from MongoDB权威指南(第3版)
218
12
打开时,服务器端会为每个写操作维护唯一的标识符,因此可以确定驱动程序何时试图重
试一个已经成功的命令。它会简单地返回一条消息表示写入成功,从而克服短暂的网络故
障所引起的问题,而不会再次进行写入。
12.2
 在写入时等待复制
根据应用程序的需要,你可能希望服务器端在将所有写操作复制到副本集大多数成员之后
再进行确认。在一些罕见的情况下,当一个副本集的主节点发生故障,并且新选出的主节
点(之前为从节点)没能复制到旧主节点的最后一次写操作时,这些写操作会在旧主节点
恢复时进行回滚。这些回滚数据可以被恢复,但需要人为进行干预。对于许多应用程序来
说,有少量回滚的写操作不是问题。例如,在一个博客应用程序中,回滚掉某位读者的一
两条评论几乎不会造成什么危害。
然而,对于其他一些应用程序,应该避免所有的写操作回滚。假设应用程序向主节点发送
了一个写操作请求,之后它收到了已经写入成功的确认,但是在所有从节点还未复制该写
入之前,主节点就崩溃了。应用程序认为能够访问到该写操作,但实际上副本集的当前成
员并没有这次写入的副本。
在某个时刻,一个从节点可能被选为主节点并开始接收新的写入。当之前的主节点恢复
时,会发现它有一些不存在于新主节点上的写操作。为了纠正这一点,它会撤销与当前主
节点的操作序列不匹配的任何写操作。这些操作不会丢失,而是会被写入特殊的回滚文件
中,这些文件必须手动应用于当前的主节点。
MongoDB
不能自动应用这些写操作
,因为
它们可能与崩溃后发生的其他写操作冲突。因此,这些写操作会消失,直到管理员有机会 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

大数据项目管理:从规划到实现

大数据项目管理:从规划到实现

Ted Malaska, Jonathan Seidman
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉
Spark快速大数据分析(第2版)

Spark快速大数据分析(第2版)

Jules S. Damji, Brooke Wenig, Tathagata Das, Denny Lee
Kafka权威指南(第2版)

Kafka权威指南(第2版)

Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty

Publisher Resources

ISBN: 9787115576538