Lune

SIGMOD2024Top-tier venue

Keep It Simple: Testing Databases via Differential Query Plans

Jinsheng Ba, Manuel Rigger

Abstract

Query optimizers perform various optimizations, many of which have been proposed to optimize joins. It is pivotal that these optimizations are correct, meaning that they should be extensively tested. Besides manually written tests, automated testing approaches have gained broad adoption. Such approaches semi-randomly generate databases and queries. More importantly, they provide a so-called test oracle that can deduce whether the system's result is correct. Recently, researchers have proposed a novel testing approach called Transformed Query Synthesis (TQS) specifically designed to find logic bugs in join optimizations. TQS is a sophisticated approach that splits a given input table into several sub-tables and validates the results of the queries that join these sub-tables by retrieving the given table. We studied TQS's bug reports, and found that 14 of 15 unique bugs were reported by showing discrepancies in executing the same query with different query plans. Therefore, in this work, we propose a simple alternative approach to TQS. Our approach enforces different query plans for the same query and validates that the results are consistent. We refer to this approach as Differential Query Plan (DQP) testing. DQP can reproduce 14 of the 15 unique bugs found by TQS, and found 26 previously unknown and unique bugs. These results demonstrate that a simple approach with limited novelty can be as effective as a complex, conceptually appealing approach. Additionally, DQP is complementary to other testing approaches for finding logic bugs. 81% of the logic bugs found by DQP cannot be found by NoREC and TLP, whereas DQP overlooked 86% of the bugs found by NoREC and TLP. We hope that the practicality of our approach---we implemented in less than 100 lines of code per system---will lead to its wide adoption.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

14 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Scaling Automated Database System Testing cites Finding bugs in database systems via query partitioning
  • Scaling Automated Database System Testing cites Detecting optimization bugs in database engines via non-optimizing reference engine construction
  • Scaling Automated Database System Testing cites Detecting Metadata-Related Logic Bugs in Database Systems via Raw Database Construction
  • Scaling Automated Database System Testing cites Testing Database Engines via Pivoted Query Synthesis
  • Detecting Schema-Related Logic Bugs in Relational DBMSs via Equivalent Database Construction cites Finding bugs in database systems via query partitioning
  • Detecting Schema-Related Logic Bugs in Relational DBMSs via Equivalent Database Construction cites Detecting optimization bugs in database engines via non-optimizing reference engine construction
  • Detecting Schema-Related Logic Bugs in Relational DBMSs via Equivalent Database Construction cites Detecting Metadata-Related Logic Bugs in Database Systems via Raw Database Construction
  • Detecting Schema-Related Logic Bugs in Relational DBMSs via Equivalent Database Construction cites APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database Systems
  • Detecting Schema-Related Logic Bugs in Relational DBMSs via Equivalent Database Construction cites Simple Testing Can Expose Most Critical Transaction Bugs: Understanding and Detecting Write-Specific Serializability Violations in Database Systems
  • Simple Testing Can Expose Most Critical Transaction Bugs: Understanding and Detecting Write-Specific Serializability Violations in Database Systems cites Detecting Schema-Related Logic Bugs in Relational DBMSs via Equivalent Database Construction
  • Detecting Schema-Related Logic Bugs in Relational DBMSs via Equivalent Database Construction cites Testing Database Engines via Pivoted Query Synthesis
  • Finding bugs in database systems via query partitioning cites Detecting optimization bugs in database engines via non-optimizing reference engine construction
  • Finding bugs in database systems via query partitioning cites APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database Systems
  • Finding bugs in database systems via query partitioning cites Testing Database Engines via Pivoted Query Synthesis
  • Detecting optimization bugs in database engines via non-optimizing reference engine construction cites APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database Systems
  • Detecting optimization bugs in database engines via non-optimizing reference engine construction cites Testing Database Engines via Pivoted Query Synthesis
  • Detecting Metadata-Related Logic Bugs in Database Systems via Raw Database Construction cites Finding bugs in database systems via query partitioning
  • Detecting Metadata-Related Logic Bugs in Database Systems via Raw Database Construction cites Detecting optimization bugs in database engines via non-optimizing reference engine construction
  • Detecting Metadata-Related Logic Bugs in Database Systems via Raw Database Construction cites APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database Systems
  • Detecting Metadata-Related Logic Bugs in Database Systems via Raw Database Construction cites Testing Database Engines via Pivoted Query Synthesis
  • APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database Systems cites Evaluating Fuzz Testing
  • Simple Testing Can Expose Most Critical Transaction Bugs: Understanding and Detecting Write-Specific Serializability Violations in Database Systems cites Finding bugs in database systems via query partitioning
  • Simple Testing Can Expose Most Critical Transaction Bugs: Understanding and Detecting Write-Specific Serializability Violations in Database Systems cites Detecting optimization bugs in database engines via non-optimizing reference engine construction
  • Simple Testing Can Expose Most Critical Transaction Bugs: Understanding and Detecting Write-Specific Serializability Violations in Database Systems cites Detecting Metadata-Related Logic Bugs in Database Systems via Raw Database Construction
  • Simple Testing Can Expose Most Critical Transaction Bugs: Understanding and Detecting Write-Specific Serializability Violations in Database Systems cites APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database Systems
  • Simple Testing Can Expose Most Critical Transaction Bugs: Understanding and Detecting Write-Specific Serializability Violations in Database Systems cites Testing Database Engines via Pivoted Query Synthesis
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers14

  1. Detecting Metadata-Related Logic Bugs in Database Systems via Raw Database ConstructionJiansen Song, Wensheng Dou, Yu Gao, Ziyu Cui et al.VLDB 2024 · 13 citations
  2. Detecting Schema-Related Logic Bugs in Relational DBMSs via Equivalent Database ConstructionJiansen Song, Wensheng Dou, Yingying Zheng, Yu Gao et al.VLDB 2025 · 6 citations
  3. Scaling Automated Database System TestingSuyang Zhong, Manuel RiggerASPLOS 2026 · 4 citations
  4. PBench: Workload Synthesizer with Real Statistics for Cloud Analytics BenchmarkingYan Zhou, Chunwei Liu, Bhuvan Urgaonkar, Zhengle Wang et al.VLDB 2025 · 4 citations
  5. Simple Testing Can Expose Most Critical Transaction Bugs: Understanding and Detecting Write-Specific Serializability Violations in Database SystemsZiyu Cui, Wensheng Dou, Yu Gao, Rui Yang et al.VLDB 2025 · 4 citations

Builds on14

  1. Evaluating Fuzz TestingGeorge Klees, Andrew Ruef, Benji Cooper, Shiyi Wei et al.CCS 2018 · 753 citations
  2. Testing Database Engines via Pivoted Query SynthesisManuel Rigger, Zhendong SuOSDI 2020 · 150 citations
  3. Finding bugs in database systems via query partitioningManuel Rigger, Zhendong SuOOPSLA 2020 · 116 citations
  4. Detecting optimization bugs in database engines via non-optimizing reference engine constructionManuel Rigger, Zhendong SuFSE 2020 · 104 citations
  5. APOLLO: Automatic Detection and Diagnosis of Performance Regressions in Database SystemsJinho Jung, Hong Hu, Joy Arulraj, Taesoo Kim et al.VLDB 2020 · 77 citations

Related papers

  1. Detecting Logic Bugs of Join Optimizations in DBMSXiu Tang, Sai Wu, Dongxiang Zhang, Feifei Li et al.SIGMOD 2023 · 34 citations
  2. Testing Database Systems via Differential Query ExecutionJiansen Song, Wensheng Dou, Ziyu Cui, Qianwang Dai et al.ICSE 2023 · 26 citations
  3. SRS: Detecting Logic Bugs of Join Implementation in DBMSs via Set Relation SynthesisJinhui Lai, Chi Zhang, Bingyan Li, Chenglin Liang et al.SIGMOD 2026 · 4 citations
  4. Pinolo: Detecting Logical Bugs in Database Management Systems with Approximate Query SynthesisZongyin Hao, Quanfeng Huang, Chengpeng Wang, Jianfeng Wang et al.USENIX ATC 2023 · 26 citations
  5. A Set-Theoretic Approach to Detecting Logic Bugs in DBMS Inner Join OptimizationsCe Lyu, Changzheng Wei, Yanhao Wang, Jie Liang et al.ICDE 2026
Dusk over the sea between two cliffs drawn in fine vertical lines