arXiv:2611.07739cs.SENov 2026

Manuscript Offprint

arXiv:2611.07739

Fix One, Miss Another: Leveraging Historical Bug Fixes to Uncover Residual Bugs in Database Systems

Yankai Rong, Zhaoyang Zhang, Shuang Liu, Wei Lu, Xiaoyong Du

YANKAI RONG, Renmin University of China, China

ZHAOYANG ZHANG, Renmin University of China, China

SHUANG LIU, Renmin University of China, China

WEI LU, Renmin University of China, China

XIAOYONG DU, Renmin University of China, China

Database management systems (DBMSs) implement SQL constructs through grammar-driven dispatch handlers. Although handlers for syntactic siblings implement different SQL constructs, they often share a common implementation pattern, including argument extraction, type checking, and permission validation. Consequently, a bug fix that hardens the handler exercised by a historical bug may leave the corresponding logic in sibling handlers vulnerable to the same semantic flaw. We refer to such defects as sibling bugs. Despite the structural similarity among sibling handlers, existing bug-finding techniques rarely exploit historical fixes to systematically uncover these related defects.

We present REAPER, a novel approach for detecting sibling bugs guided by historical bug fixes. REAPER first analyzes a bug fix to infer a trigger profile, which characterizes the conditions under which the defect is exposed, and a validation profile, which captures the semantic evidence needed to distinguish buggy behavior from correct behavior. It then projects the trigger profile onto syntactic siblings through grammar-guided test mutation, generating tests that exercise corresponding semantic paths in sibling handlers. Finally, REAPER validates suspicious behaviors using the inferred validation profile through a staged validation process, reducing false positives caused by complex DBMS behavior.

We evaluate REAPER on four widely used DBMSs—MariaDB, MySQL, OceanBase, and CockroachDB. REAPER uncovers 61 previously unknown bugs, of which 57 have been confirmed by developers and 13 have been fixed at the time of writing. These results demonstrate that historical bug fixes contain actionable semantic knowledge that can be systematically transferred across syntactic siblings to uncover otherwise overlooked defects.

1 Introduction

The Structured Query Language (SQL) is a declarative language whose behavior is specified in the ISO/IEC 9075 standard [6]. Each syntactic element/construct of the standard is defined through a format expressed as a BNF production, accompanied by the Syntax Rules, Access Rules, and General Rules that govern its processing. Modern DBMSs [3, 17, 19, 20] implement these specifications through a grammar-driven architecture: a recognized SQL construct is routed by a dispatcher to a dedicated handler responsible for its execution. This recurring architectural pattern is what we call the handler dispatch pattern [12, 21–24, 31].

The handler dispatch structure is directly mirrored by a grammar's production rule: the left-hand-side non-terminal of a production rule corresponds to the dispatcher, and its right-hand-side alternatives correspond to the construct-specific handlers. Figure 1(b) illustrates this correspondence through the MariaDB sequence functions NEXTVAL and SETVAL. These two constructs originate from the same left-hand-side non-terminal in the BNF grammar and share similar semantics—both resolve a sequence object and then apply a form-specific effect. In the implementation, the virtual

Authors' Contact Information: Yankai Rong, yankairong@ruc.edu.cn, Renmin University of China, Beijing, China; Zhaoyang Zhang, zhaoyangzhang@ruc.edu.cn, Renmin University of China, Beijing, China; Shuang Liu, Shuang.Liu@ruc.edu.cn, Renmin University of China, Beijing, China; Wei Lu, lu-wei@ruc.edu.cn, Renmin University of China, Beijing, China; Xiaoyong Du, duyong@ruc.edu.cn, Renmin University of China, Beijing, China.

Figure

Fig. 1. Reaper Reveals an Unpropagated Fix in MariaDB.

function Item::val_int() serves as the dispatcher; the functions Item_func_nextval::val_int() and Item_func_setval::val_int() are the two sibling handlers responsible for NEXTVAL and SETVAL, respectively.

Because sibling handlers share substantial common logic, they should evolve together: a bug uncovered in one handler is a strong signal that an analogous bug may exist in its siblings. In practice, however, developers fix a system based on a reported bug, which typically pinpoints only one handler. A fix applied to one handler therefore often leaves its siblings exposed to the same bug—a phenomenon we term a sibling bug.

Figure 1(c) illustrates a sibling bug we identified in MariaDB, with respect to a historical bug shown in Figure 1(a). The constructs NEXTVAL and SETVAL originate from the same BNF production and both require their argument to resolve to a valid sequence object. The original bug, BUG #33985, was fixed by adding an is_pure_alias() guard only to the NEXTVAL handler; the accompanying regression test exercised only this construct. The sibling handler SETVAL was therefore left unfixed despite sharing an analogous implementation. Replacing NEXTVAL in the original bug triggering query with SETVAL therefore exercised analogous processing logic in the sibling handler and still triggered a server crash. We reported this sibling bug as BUG #39063, whose follow-up fix propagated the same guard to the SETVAL handler.

However, systematically detecting sibling bugs remains non-trivial. Existing DBMS fuzzers explore syntactic spaces or execution paths [1, 2, 7, 11, 25, 27, 29, 31], but cannot exercise sibling handlers that may remain inconsistent after repairing the reported bugs. Bridging this gap requires overcoming three challenges:

First, precisely recovering the bug-triggering and bug-validation conditions. Historical fix records often contain noisy and lengthy context, making it difficult to recover the bug-triggering conditions and the semantic evidence used to distinguish buggy behavior from correct behavior. The challenge is thus to distill a historical fix into a concise and actionable profile that captures both when the bug can be triggered and how its manifestation can be validated.

Second, systematically exercising sibling handlers while preserving bug-triggering conditions. Blindly mutating a historical bug-triggering query does not systematically reach handlers implementing syntactic siblings of the original construct. More importantly, simply replacing the original construct with a sibling alternative may invalidate the conditions that expose the historical defect. Effective sibling testing therefore requires simultaneously satisfying two constraints: the generated query must be routed to the intended sibling handler, while preserving the relevant semantic conditions under which the historical bug is triggered. The challenge is to transform a historical bug-triggering query across syntactic siblings without losing its defect-triggering characteristics.

Third, accurately validating sibling bugs without ground truth. Unlike conventional regression testing, a sibling query generally has no known expected result. It is also not necessarily semantically equivalent to the historical bug-triggering query, making direct result comparison inappropriate. Existing DBMS testing oracles based on equivalence-oriented metamorphic relations [22, 23, 26] or approximation relations [14] therefore cannot be directly applied to determine whether a suspicious sibling execution exhibits the same semantic defect. The challenge is to derive validation evidence from the historical fix and determine whether the sibling execution violates the semantic property associated with the original bug, without a predefined ground-truth result.

To address these challenges, we present REAPER, a DBMS fuzzing framework that turns historical bug fixes into reusable probes for detecting sibling bugs. REAPER follows a profile-generate-validate pipeline consisting of three phases. Bug Profile Construction addresses the challenge of recovering actionable triggering and validation conditions from noisy fixes. We design a multi-agent system consisting of a Query Analyzer, a Patch Analyzer and an Orchestrator. The Query Analyzer identifies the bug-triggering construct and historical failure pattern, while the Patch Analyzer infers the correctness requirement from the fix. The Orchestrator reconciles these complementary findings into a Bug Profile containing trigger conditions and validation evidence. Sibling Test Generation addresses the challenge of reaching sibling handlers while preserving bug-triggering conditions. REAPER identifies sibling constructs from the SQL grammar and transforms historical bug-triggering queries to exercise those sibling handlers. A Concretizer then satisfies sibling-specific semantic constraints while preserving the relevant trigger conditions in the Bug Profile. Sibling Bug Validation addresses the challenge of validating sibling bugs without ground truth. REAPER validates sibling-bug candidates through a three-stage checking process: failure-pattern matching, criterion applicability checking, and fix-derived oracle checking. These stages reuse semantic evidence from the historical fix to determine whether sibling executions violate the corresponding correctness requirement. We evaluated REAPER on four widely used production DBMSs—MariaDB, MySQL, OceanBase, and CockroachDB. It uncovered 61 previously unknown bugs, including 50 logic bugs and 11 crash/fatal-error bugs; 57 have been confirmed and 13 have been fixed by upstream developers.

In summary, this paper makes the following contributions:

  • Insight. We identify sibling bugs, a class of residual DBMS bugs that arise when a localized fix corrects one implementation while a related sibling handler remains vulnerable to the same semantic flaw. We further observe that historical bug fixes encode actionable knowledge about both bug-triggering conditions and correctness requirements, which can serve as semantic anchors for systematically examining sibling implementations.
  • Methodology. We design and implement REAPER, a fix-guided DBMS fuzzing framework following a profile-generate-validate pipeline. REAPER constructs a Bug Profile from historical bug fix reports, identifies sibling constructs through a grammar relation graph, and generates sibling tests while preserving the historical triggering conditions. It then validates suspicious executions using fix-derived validation evidence, without requiring ground-truth results.
  • Real-world impact. We evaluate REAPER on MySQL, MariaDB, OceanBase, and CockroachDB. It uncovers 61 previously unknown bugs, including 50 logic bugs and 11 crash or fatal-error bugs. Among them, 57 have been confirmed and 13 have been fixed by upstream developers. These results demonstrate that incomplete repair propagation remains a practical maintenance challenge in real-world DBMSs and that REAPER provides a way to systematically identify such residual bugs.