MongoDB is a popular general-purpose, document-oriented, distributed NoSQL database. It supports transactions in three different deployments: single-document transactions utilizing the WiredTiger storage engine in a standalone node, multi-document transactions in a replica set which consists of a primary node and several secondary nodes, and distributed transactions in a sharded cluster which is a group of multiple replica sets, among which data is sharded. A natural and fundamental question about MongoDB transactions is: What transactional consistency guarantee do MongoDB Transactions in each deployment provide? However, it lacks both concise pseudocode of MongoDB transactions in each deployment and formal specification of the consistency guarantees which MongoDB claimed to provide. In this work, we formally specify and verify the transactional consistency protocols of MongoDB. Specifically, we provide a concise pseudocode for the transactional consistency protocols in each MongoDB deployment, namely WIREDTIGER, REPLICASET, and SHARDEDCLUSTER, based on the official documents and source code. We then prove that WIREDTIGER, REPLICASET, and SHARDEDCLUSTER satisfy different variants of snapshot isolation, namely Strong-SI, Realtime-SI, and Session-SI, respectively. We also propose and evaluate efficient white-box checking algorithms for MongoDB transaction protocols against their consistency guarantees, effectively circumventing the NP-hard obstacle in theory.
翻译:MongoDB是一个广受欢迎的通用、以文件为导向、分布式的NOSQL数据库。它支持三种不同的交易:单文档交易,使用WiredTiger存储引擎的独立节点,多文档交易,复制集的多文档交易,由初级节点和几个二级节点组成,分散在碎裂的组群中,由多种复制组组成,其中数据被分割。关于MongoDB交易的自然和根本问题是:MongoDB交易在每次部署中提供什么样的交易一致性保证?然而,它缺乏每次部署中的MongoDB交易的简明假码,以及MongoDBA声称提供的一致性保证的正式规格。在这项工作中,我们正式指定和核查MongoDBDB的交易一致性协议。具体地说,我们为每次部署MongDBDB的会计一致性协议提供了简洁的假码,即WiREDTIGER、REPICAST和SADFSA的透明性协议,我们随后证明WA-BRO-CF-CRODF-CRODF AS 和SARVARVDRVDF-CS-CS-S-CRVADRVDF AS-CRVDRVDORDAR AS AS AS-CRV 有效保证。