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版)
168
8
证数据和数据库状态的有效性,即使在出现断电或其他错误的情况下也是如此。
原子性确保了事务中的所有操作要么都被应用,要么都不被应用。事务永远不能应用部分
操作,要么被提交,要么被中止。
一致性确保了如果事务成功,那么数据库将从一个一致性状态转移到下一个一致性状态。
隔离性是允许多个事务同时在数据库中运行的属性。它保证了一个事务不会查看到任何其他
事务的部分结果,这意味着多个事务并行运行与依次运行每个事务所获得的结果相同。
持久性确保了在提交事务时,即使系统发生故障,所有数据也都会保持持久化。
当数据库满足所有这些属性并且只有成功的事务才会被处理时,它就被称为是符合
ACID
的数据库。如果在事务完成之前发生故障,那么
ACID
确保不会更改任何数据。
MongoDB
是一个分布式数据库
,它支持跨副本集和
/
或分片的
ACID
事务。网络层增加了
额外的复杂性。
MongoDB
的工程团队提供了一些记录和谈话视频
,描述了他们是如何实
现支持
ACID
事务的必要特性的。
8.2
 如何使用事务
MongoDB
提供了两种
API
来使用事务。第一种是与关系数据库类似的语法(如
start_
transaction
commit_transaction
),称为核心
API
;第二种称为回调
API
,这是使用事
务的推荐方法。
核心
API
不为大多数错误提供重试逻辑
,它要求开发人员为操作、事务提交函数以及所需
的任何重试和错误逻辑手动编写代码。
与核心
API
同,回调
API
提供了一个单独的函数,该函数封装了大量功能,包括启动与
指定逻辑会话关联的事务、执行作为回调函数提供的函数以及提交事务(或在出现错误时 ...
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