NoSQL databases are widely used in modern applications due to their scalability and schema flexibility, yet they often rely on eventual consistency models that limit reliable transaction processing. This study proposes a four-stage transaction management framework for document-oriented NoSQL databases, with MongoDB as the reference platform. The framework combines transaction lifecycle management, operation classification, pre-execution conflict detection, and an adaptive locking strategy with timeout-based deadlock prevention. Formal correctness analysis shows that the proposed approach guarantees conflict serializability under defined conditions. An experimental evaluation using the Yahoo Cloud Serving Benchmark (YCSB) workloads A, B, and F, with concurrency levels ranging from 1 to 100 clients, demonstrates a reduction in transaction abort rates from 8.3% to 4.7%, the elimination of observed deadlocks, and a 34.2% decrease in latency variance. Throughput improvements ranging from 6.3% to 18.4% are observed under high concurrency, particularly for read-modify-write workloads. Distributed experiments on clusters of up to 9 nodes confirm scalability, achieving 15.2% higher throughput and 53% lower abort rates than baseline systems. Comparisons with MongoDB's native transactions, CockroachDB, and TiDB indicate that the proposed framework strikes a good balance between consistency guarantees and performance overhead. Sensitivity analysis identifies optimal parameter settings, including a lock timeout of 100 ms, an initial backoff of 10 ms, and a maximum backoff of 500 ms. These results show that carefully designed consistency mechanisms can significantly improve data integrity in NoSQL systems without undermining scalability.
翻译:NoSQL数据库因其可扩展性和模式灵活性而在现代应用中得到广泛使用,但它们通常依赖最终一致性模型,这限制了可靠的事务处理。本研究针对面向文档的NoSQL数据库(以MongoDB为参考平台)提出一个四阶段事务管理框架。该框架结合了事务生命周期管理、操作分类、预执行冲突检测以及基于超时的死锁预防自适应锁策略。形式化正确性分析表明,所提方法在定义条件下能保证冲突可串行化。使用Yahoo Cloud Serving Benchmark(YCSB)工作负载A、B和F进行的实验评估(并发客户端数从1到100)显示:事务中止率从8.3%降至4.7%,观测到的死锁被消除,延迟方差降低34.2%。在高并发场景下(特别是读-修改-写工作负载)观察到吞吐量提升6.3%至18.4%。在最多9个节点的集群上进行的分布式实验证实了可扩展性,相比基线系统实现了15.2%的吞吐量提升和53%的中止率降低。与MongoDB原生事务、CockroachDB及TiDB的对比表明,所提框架在一致性保证与性能开销间取得了良好平衡。敏感性分析确定了最优参数设置,包括100毫秒的锁超时、10毫秒的初始退避和500毫秒的最大退避。这些结果表明,精心设计的一致性机制能在不损害可扩展性的前提下,显著提升NoSQL系统的数据完整性。