Abstract
Database isolation levels (ILs) serve as a critical contract between applications and database management systems (DBMS), yet verifying compliance is challenging due to non-determinism and the "black-box" nature of many modern systems. This paper introduces Leopard, a novel black-box test suite that employs "mechanism-mirrored verification." By simulating concurrency control logic using client-side time intervals, Leopard achieves high scalability and generality. Evaluation across major systems like MySQL, PostgreSQL, and TiDB led to the discovery of 24 bugs, demonstrating Leopard's effectiveness in catching consistency anomalies that traditional tools miss.
Introduction
Isolation levels define how concurrent transactions interact to prevent data corruption. However, verifying these levels in modern DBMSs faces significant hurdles:
- Inaccessibility: Cloud-based services often hide internal source code.
- Non-determinism: Unpredictable transaction ordering complicates trace analysis.
- Implementation Diversity: "Repeatable Read" may vary significantly between vendors.
- Performance: High throughput often outpaces verification tools relying on complex graph searches.
Leopard addresses these by moving away from exhaustive cycle searching toward a protocol-simulation approach that mirrors the database's internal mechanisms.
System Architecture and Methodology
Leopard's core innovation is mechanism-mirrored verification. Instead of post-hoc error searching, it simulates the logic of standard concurrency control protocols.
Mechanism-Mirrored Verification
The system models isolation levels using four fundamental mechanisms:
- Consistent Read (CR): Ensures transactions observe a consistent data snapshot.
- Mutual Exclusion (ME): Simulates lock-based behaviors to prevent concurrent conflicting access.
- First Updater Wins (FUW): Prevents lost updates by ensuring only the first of two concurrent updates to a record succeeds.
- Serialization Certifier (SC): Detects complex dependency cycles such as write-skew.
Interval-Based Tracing
To handle the "black-box" nature of databases, Leopard records client-side time intervals ($ts_{start}$ to $ts_{end}$). These intervals allow Leopard to deduce temporal dependencies. If two intervals do not overlap, their order is fixed; if they do, Leopard identifies a "candidate set" of valid data versions, significantly reducing the search space compared to traditional graph-based methods.
Evaluation
Leopard was evaluated using industry-standard benchmarks (SmallBank, TPC-C) against a suite of popular databases including MySQL, PostgreSQL, TiDB, OceanBase, and openGauss.
Key Results
- Bug Discovery: Leopard identified 24 bugs across commercial and open-source DBMSs. At publication, 16 were confirmed and 14 fixed.
- Detection Accuracy: Leopard outperformed state-of-the-art tools like Elle and Cobra by identifying snapshot versioning errors that those tools missed due to their disregard for time-order constraints.
- Scalability: By sharding traces based on data keys and utilizing a two-level pipeline (local buffers and a global min-heap), Leopard scales horizontally to match high-throughput production workloads.
Conclusion and Future Work
Leopard demonstrates that simulating database protocols is a more efficient path to verification than traditional graph searches. While highly effective, future work includes integrating Leopard with automated "adversarial" workload generators (fuzzers) to proactively trigger edge-case anomalies and further optimizing inter-node communication for the Serialization Certifier in massive distributed environments.
Summary updated