Manuscript Offprint
arXiv:2611.07739Fix One, Miss Another: Leveraging Historical Bug Fixes to Uncover Residual Bugs in Database Systems
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.

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.
2.1 Grammar-Driven SQL Processing in DBMSs
Modern DBMSs typically process an SQL query through several stages, including parsing, semantic analysis, optimization, and execution. After receiving a query, the DBMS first parses the input according to its SQL grammar to determine its syntactic structure and creates an internal representation for each recognized SQL construct. Throughout this process, different SQL constructs may be routed to different processing paths according to handler-selection information encoded in their internal representations, e.g., construct types, expression classes, or function/operator identifiers.
SQL grammars provide a structural bridge between SQL constructs and these processing paths. ISO/IEC 9075 specifies SQL syntactic elements using BNF-style productions, while practical DBMSs maintain dialect grammars to describe their supported SQL constructs [6]. A production rule associates a left-hand-side nonterminal with one or more right-hand-side alternatives, each defining a distinct syntactic form of that nonterminal. As shown in Figure 1(b), in MariaDB, the grammar alternative for the SQL construct NEXTVAL is recognized during parsing and mapped to an Item_func_nextval object in the internal representation. During evaluation, the object is dispatched through the Item::val_int() interface to its handler Item_func_nextval::val_int(), which implements the sequence operation. This example illustrates the correspondence between grammar alternatives and construct-specific processing paths, where sibling alternatives may lead to distinct handlers implementing related semantics.
2.2 Syntactic Siblings and Handler Dispatch
Definition 1 (Syntactic Sibling). We refer to SQL constructs derived from different alternatives of the same left-hand-side nonterminal as syntactic siblings.
Although syntactic siblings denote different SQL constructs, their shared grammatical role often leads them to enter the same processing framework before diverging into construct-specific behavior. Figure 1(b) illustrates NEXTVAL and SETVAL as syntactic siblings in MariaDB. Their grammar alternatives, NEXTVAL_SYM ('table_ident') and SETVAL_SYM ('table_ident', '...'), share the same left-hand-side nonterminal. Here, NEXTVAL_SYM and SETVAL_SYM are grammar tokens representing the SQL keywords NEXTVAL and SETVAL, respectively. At the implementation level, this grammar structure is reflected by the handler dispatch pattern. A handler is the implementation selected by a dispatch decision to process a particular SQL construct. It may be realized as a dedicated function or method, or as a distinct branch within a shared implementation.
Definition 2 (Sibling Handler). Sibling handlers are handlers implementing syntactic siblings.
As shown in Figure 1(b), NEXTVAL and SETVAL are represented by Item_func_nextval and Item_func_setval within the same expression-processing framework. They share common preparation and evaluation interfaces. During evaluation, calls through the shared virtual interface Item::val_int() are dispatched to Item_func_nextval::val_int() or Item_func_setval::val_int(), selecting the handler of the corresponding construct. Sibling handlers may further reuse preparation logic and auxiliary routines for object resolution, argument processing, and validation, while retaining separate execution paths for construct-specific semantics.
2.3 Sibling Bugs
In a typical DBMS development workflow, a reported bug is reproduced by a failing query and localized to an implicated processing path. Developers patch that path and add a regression test to check that the historical failure does not recur. The patch therefore determines which implementation path is updated, while the regression test determines which triggering instance

Fig. 2. Overview of REAPER.
is exercised after the fix. Because both are typically centered on the reported construct, neither necessarily covers the construct-specific paths associated with its syntactic siblings.
This distinction matters when sibling handlers follow different execution paths but are subject to the same correctness requirement. A repair confined to the reported path may correct the historical violation without updating the corresponding logic in a sibling path. The original regression test can therefore pass while another grammar alternative still reaches an implementation that violates the same requirement. In the motivating example in Figure 1, the repaired NEXTVAL handler rejects an invalid sequence reference, whereas the sibling SETVAL handler still crashes on the same reference. Both handlers should reject such references, but the historical fix corrects only the NEXTVAL path. We formally define such residual bugs as follows:
Definition 3 (Sibling Bug). Two bugs are sibling bugs if they occur in sibling handlers and share the same bug-triggering conditions.
Figure 1 illustrates how a localized fix leaves a sibling bug unresolved in MariaDB. The historical query calls NEXTVAL (x), where x does not refer to a sequence object. Instead of rejecting this invalid reference, the handler attempts to access it as a sequence object and crashes. The historical fix adds a check to reject the reference before sequence-object access, and the accompanying regression test verifies the repaired NEXTVAL path. However, the sibling SETVAL handler lacks the corresponding check. Replacing NEXTVAL (x) with SETVAL (x, 1) retains the invalid reference while directing execution to this sibling handler. Although both constructs require a valid sequence reference, the SETVAL path still attempts sequence-object access and crashes, as shown in Figure 1(c).
3 Approach
Figure 2 provides an overview of REAPER, which consists of three components—Bug Profile Construction, Sibling Test Generation, and Sibling Bug Validation. Given a historical fix, REAPER generates and executes sibling tests to uncover sibling bugs. During Bug Profile Construction, three collaborating LLM agents analyze the regression test, bug description, and patch, integrating query-side and repair-side evidence into a Bug Profile comprising a trigger profile and a validation profile (§3.1). Then, the trigger profile guides Sibling Test Generation to produce sibling test cases that preserve the bug-triggering conditions (§3.2). Sibling Bug Validation then applies the validation profile in three stages. A sibling bug is reported only when the execution matches the failure pattern, the fix-derived criterion applies to the selected sibling, and the corresponding oracle, adapted to the sibling test, is violated (§3.3).

Fig. 3. Bug Profile Construction.
3.1 Bug Profile Construction
Turning fixes into probes requires lifting path-local repair evidence into sibling-oriented bug knowledge. Our key insight is that historical fixes encode bug knowledge in a path-specific form while sibling testing requires transforming this local evidence into reusable sibling-oriented knowledge for Sibling Test Generation and Sibling Bug Validation. To support this transition, REAPER organizes the historical evidence into a structured Bug Profile . Before describing how is constructed, we first define what it contains and why each part is needed for sibling testing.
Definition 4 (Bug Profile). We define the Bug Profile as , where is the trigger profile and is the validation profile. The trigger profile is defined as , where is the bug-triggering construct whose execution reaches the code fixed by the historical fix, is the key statement in the regression test that contains the , and is the complete regression test. The validation profile is defined as , where is the failure pattern, is the fix-derived criterion, expressed as a specification of expected SQL behavior inferred from the patch and bug description, and is the fix-derived oracle, specifying a checkable condition or relation for determining incorrect execution behavior under the conditions specified in the oracle.
The trigger profile provides the historical context needed for Sibling Test Generation. identifies the bug-triggering construct whose syntactic siblings are selected for testing, while provides the statement containing that construct and the surrounding SQL structure needed for mutation. retains the complete regression test, including the object definitions, data and session settings needed to expose the historical bug. Together, these components allow sibling tests to exercise a different construct while preserving the bug-triggering conditions.
The validation profile provides three complementary checks for Sibling Bug Validation. supports matching the failure pattern across their executions. provides the specification inferred from the historical fix, whose applicability is assessed using the selected sibling's SQL semantics and execution context. provides a concrete condition or relation for checking whether the candidate execution is incorrect under the stated conditions. The validation profile provides task-specific context for LLM-based reasoning about sibling bugs and improves the accuracy of sibling-bug detection by reducing false positives caused by valid semantic differences between sibling constructs.
Bug Profile construction. Constructing an accurate Bug Profile from a historical fix is challenging for two reasons. (i) It is difficult to pinpoint the bug-triggering construct because the observed failure reflects the interaction of multiple SQL constructs and their context. In Figure 3, the incorrect result involves COUNT, DISTINCT, GROUP BY, and a BIT-typed argument. The description emphasizes BIT representation, and the patch introduces special handling for FIELD_TYPE_BIT. These clues explain the circumstances of the failure, but their prominence can lead an LLM to select a triggering condition rather than the construct corresponding to the repaired handler. For example, selecting DISTINCT instead of COUNT would change which sibling handlers are subsequently tested. (ii) It is difficult to recover the fix-derived oracle because a patch records the concrete repair mechanism, leaving the restored SQL behavior implicit. In Figure 3, the patch converts BIT values to BIGINT in temporary tables, while the failure manifests as an incorrect result under DISTINCT. The explicit type conversion can therefore draw an LLM toward implementation details and obscure the expected behavior: DISTINCT should preserve the complete logical BIT value.
To address these challenges, REAPER employs three collaborating LLM agents to construct the Bug Profile. For the first challenge, REAPER adopts a cross-checking mechanism over independently inferred bug-triggering constructs. The Query Analyzer infers from the original regression test and the bug description , while the Patch Analyzer maps the repaired handler in the code patch to its corresponding SQL construct, yielding . The Orchestrator confirms only when the two results refer to the same SQL construct, thereby reducing the possibility of selecting a surrounding trigger condition. For the second challenge, REAPER designs the Patch Analyzer instructions to introduce intermediate reasoning steps between the concrete code change and the validation profile. These steps guide the derivation of and from and .
Query Analyzer. The Query Analyzer aims to recover the SQL-side information from the regression test and bug description . To identify , REAPER designs instructions (shown in Figure 3) that direct the LLM to use the diagnostic clues in to distinguish the bug-triggering construct in from surrounding trigger conditions. The instructions further require the analyzer to preserve the complete regression test as , extract the complete statement containing as , and abstract the incorrect behavior described by and into the failure pattern . In Figure 3, although COUNT, DISTINCT, GROUP BY, and the BIT-typed argument all appear in the failing query, the instructions direct the analyzer to identify COUNT as .
Patch Analyzer. The Patch Analyzer aims to recover the repair-side information from the bug description and code patch . To obtain both and the validation profile, REAPER designs the instructions with intermediate reasoning steps. Specifically, the analyzer first traces the repaired handler in to its corresponding SQL construct, yielding . It then interprets the code change together with the information in and infers as a specification of the expected SQL behavior. The instructions also direct the analyzer to identify the conditions and formulate as a checkable condition or relation for determining incorrect execution behavior. In Figure 3, the modification to Item_sum_count_distinct::setup() is mapped to COUNT. By analyzing the BIT(N) representation described in together with the BIT-to-BIGINT change in , the analyzer infers that COUNT(DISTINCT ...) should distinguish BIT-valued arguments by their logical values.
Orchestrator. The Orchestrator coordinates the two analyzers through the cross-checking mechanism. Specifically, it compares and together with their corresponding findings and
Algorithm 1 Sibling Test Generation
1: input Trigger Profile , grammar graph 2: output Sibling tests 3: ast ← Parse() 4: anchor ← MATCHCONSTRUCT(as, ) 5: 6: 7: 8: for all do 9: fragment ← INSTANTIATE ALTERNATIVE() 10: 11: 12: if then 13: 14: end if 15: end for 16: return

Fig. 4. Sibling Test Generation.
confirms when the two analyses refer to the same SQL construct. When they disagree, the Orchestrator returns the conflicting findings to the analyzers for re-analysis and filters out fixes whose disagreement remains unresolved. After confirming , it constructs the trigger profile from , , and , and the validation profile from , , and . Together, the two profiles constitute the final Bug Profile .
3.2 Sibling Test Generation
With the trigger profile recovered from a historical fix, REAPER extends testing from the reported construct to its syntactic siblings while retaining the context that makes the historical bug relevant. The challenge is to redirect execution to a sibling handler while preserving the bug-triggering conditions inherited from the historical test. To achieve this, REAPER applies Grammar-Guided Sibling Mutation to identify grammar-defined siblings and construct statement skeletons through localized substitution. Guided by the trigger profile, an LLM-based Concretizer then performs Trigger-Constrained Concretization to complete these skeletons with sibling-specific operands, bindings, and execution requirements while preserving the historical bug-triggering context.
3.2.1 Grammar-Guided Sibling Mutation. REAPER uses the syntactic-sibling relation defined in §2 to identify alternatives to the bug-triggering construct recorded in the trigger profile. Algorithm 1 summarizes the complete sibling test generation procedure. To support sibling discovery, REAPER represents the target DBMS grammar as a grammar graph , where production alternatives are connected through the nonterminals they reference. Given the trigger profile and , REAPER locates the occurrence of associated with the historical failure in the AST of and maps it to the corresponding grammar production . Starting from the alternative productions of , REAPER performs a breadth-first search (BFS) that expands unit productions but does not descend into the internal nonterminals of concrete constructs (Line 6). A concrete alternative is retained as a sibling candidate if its construct differs from . Each production is processed at most once, and the search terminates when the queue is empty.
For each sibling alternative, REAPER uses its production as the structural template for a replacement fragment. INSTANTIATE ALTERNATIVE matches nonterminal occurrences by symbol and occurrence order, filling matched occurrences with the corresponding historical subtrees unchanged. Unmatched nonterminal occurrences remain as placeholders for sibling-specific components. The fragment then replaces only the selected historical occurrence in to obtain the statement skeleton (Line 10). This local replacement preserves both the historical subtrees reused within the fragment and the surrounding statement structure outside it. The complete regression test is passed separately to the Concretizer, which uses the historical setup and execution context to complete the skeleton and satisfy sibling-specific semantic requirements.
Figure 4 illustrates this process for NEXTVAL. The grammar identifies SETVAL as a sibling construct. Since both alternatives contain table_ident, REAPER reuses the historical subtree x. The additional value expression required by SETVAL has no historical counterpart and is left as a placeholder, yielding SETVAL(x, ☐). Replacing the selected NEXTVAL(x) occurrence with this fragment produces the sibling statement skeleton while preserving the historical bug-triggering conditions.
3.2.2 Trigger-Constrained Concretization. REAPER employs an LLM-based Concretizer to complete the sibling statement skeleton (Line 11). The Concretizer receives the skeleton constructed from and , together with the complete historical regression test from the trigger profile. The skeleton specifies the selected sibling and its unresolved components, while provides the historical statements, definitions, and bindings required to complete the sibling test without discarding the historical bug-triggering context.
The Concretizer first compares with to identify the operands and additional requirements introduced by the sibling construct. For unresolved components, it consults the grammar graph to restrict their completion to alternatives permitted by the corresponding grammar productions. It then examines to determine which definitions and bindings are used by the reused subtrees and must therefore be retained. Based on this information, the Concretizer completes the unresolved components while introducing new elements only where required by the sibling construct. A completion is accepted only if it conforms to the grammar and satisfies the additional requirements while retaining the statements and bindings relevant to the historical bug-triggering context; otherwise, the Concretizer returns and the candidate is discarded.
Figure 4 illustrates this process for SETVAL(x, ☐). The Concretizer first identifies the additional value argument required by SETVAL. It then examines and identifies that x refers to a CTE whose pure-alias binding is required to trigger the historical bug. Replacing x with an ordinary sequence name would satisfy the object requirement of SETVAL, but would remove this historical binding. The Concretizer therefore retains the CTE definition and its reference and supplies 1 for the unresolved value expression, yielding SETVAL(x, 1).
3.3 Sibling Bug Validation
Syntactic siblings may implement different semantics and consequently produce different valid results. Sibling bug validation therefore requires semantic reasoning about the execution result of a sibling test , beyond direct comparison with the historical execution result. LLMs can support this reasoning using their knowledge of SQL semantics and open-source DBMS implementations. However, such general knowledge alone may be insufficient for judging a particular sibling test. Without information specific to the historical bug, the model may rely on unsupported assumptions about the selected sibling and its execution result.
To provide a basis for these judgments, REAPER uses the Validation Profile recovered from the historical fix to guide three LLM agents. Each agent follows intermediate reasoning steps organized around the corresponding profile component. The three judgments serve distinct purposes. The first uses to restrict validation to executions exhibiting the historical failure pattern. The second uses to assess whether the specification recovered from the historical fix applies to the selected sibling. The third evaluates to establish whether the execution result is incorrect under the conditions specified in the oracle, since criterion applicability alone does not establish incorrect execution behavior. Figure 5 uses MariaDB MDEV-33496 to illustrate the validation process. The historical bug occurs when CREATE ... AS SELECT derives a result column for AVG(YEAR(a)). The implementation did not correctly account for the range of

Fig. 5. LLM-based Sibling Bug Validation guided by the validation profile.
non-negative datetime-component functions when deriving the DECIMAL type for AVG, producing a column with insufficient integer capacity and raising ERROR 1264 for otherwise valid inputs. The historical fix corrects the type handling for these functions so that the derived DECIMAL type can represent the resulting value. Starting from this fix, REAPER generates a sibling test by replacing YEAR(a) with TO_DAYS(a) and validates its execution using the recovered validation profile.
Stage I: Match Failure Pattern. The first agent determines whether the execution result of exhibits the historical failure pattern, restricting further validation to candidates relevant to the historical bug. Given , , and its execution result, the prompt guides the agent through three reasoning steps. First, the agent identifies the failure pattern specified by . Second, it examines the corresponding behavior in the execution result. Finally, it determines whether exhibits based on these intermediate judgments. The comparison considers the failure described by the pattern and the operation in which it occurs, without requiring identical concrete outputs. In Figure 5(a), describes ERROR 1264 when CREATE TABLE ... AS SELECT stores an AVG result. The agent identifies an out-of-range error in the execution of the statement containing AVG(TO_DAYS(a)) and relates this error to the historical failure pattern. It therefore returns MATCH, for which is true. A No_MATCH decision excludes the candidate from further validation.
Stage II: Check Criterion Applicability. The second agent determines whether the specification in applies to the selected sibling. This judgment is necessary because a matching failure pattern does not establish that the fix-derived criterion is applicable to the sibling's semantics. Given and , the prompt first directs the agent to identify the specification in . Second, the agent examines the selected sibling's semantics together with its use in . Finally, it assesses whether the specification applies to the selected sibling in that statement. In Figure 5(b), specifies that
Table 1. Unknown bugs found by REAPER.
| Database System | Crash/Fatal Bugs | Logic Bugs | Total | ||||
|---|---|---|---|---|---|---|---|
| Pending | Confirmed | Fixed | Pending | Confirmed | Fixed | ||
| MariaDB | 0 | 4 | 1 | 0 | 19 | 2 | 23 |
| MySQL | 0 | 0 | 0 | 0 | 15 | 1 | 15 |
| OceanBase | 0 | 2 | 0 | 3 | 4 | 0 | 9 |
| CockroachDB | 0 | 5 | 1 | 1 | 8 | 8 | 14 |
| Total | 0 | 11 | 2 | 4 | 46 | 11 | 61 |
CREATE TABLE . . . AS SELECT should preserve the computed AVG result for valid temporal-function outputs when inferring the result-column type. The agent identifies that TO_DAYS(a) produces the values consumed by AVG within CREATE TABLE . . . AS SELECT. It therefore concludes that the specification applies to this use of TO_DAYS(a) and returns APPLICABLE, for which is true. A NOT_APPLICABLE decision excludes the candidate from the next stage.
Stage III: Check Oracle Violation. The third agent determines whether the execution result violates the condition or relation specified in . Given , , and its execution result, the prompt organizes the judgment into three reasoning steps. First, the agent checks the conditions specified in against and its execution result. Second, it compares the condition or relation in with the corresponding execution result. Finally, it assesses the oracle result based on the condition checks and evaluation. In Figure 5(c), requires that, for AVG over a non-negative datetime component, the integer capacity of the inferred DECIMAL type be no smaller than that required by the resulting value. In the illustrated reasoning, the agent first determines that the conditions in hold for . It then interprets the out-of-range error as indicating that the inferred DECIMAL type cannot represent the resulting AVG value. On this basis, the agent concludes that the inferred integer capacity is smaller than that required by the result and returns VIOLATED. Accordingly, is true only when the conditions hold and the agent determines that the condition or relation in is violated.
REAPER reports a sibling bug only when the three agents return MATCH, APPLICABLE, and VIOLATED, respectively:
4 Evaluation
To evaluate the effectiveness of REAPER in detecting sibling bugs in real-world DBMSs, we address the following four research questions:
-
RQ1: How effective is REAPER at discovering sibling bugs in real-world DBMSs?
-
RQ2: How does REAPER compare with existing DBMS fuzzers?
-
RQ3: How do REAPER's key test-generation components contribute to sibling-bug discovery?
-
RQ4: How effectively does REAPER distinguish logic sibling bugs from benign behavior?
4.1 Evaluation Setup
4.1.1 Environment. We conducted all experiments on a machine running 64-bit Ubuntu 22.04.5 LTS, equipped with an Intel(R) Xeon(R) Gold 6454S CPU with 128 cores and 512 GB of RAM. All LLM-based components in REAPER use DeepSeek-V4-Flash through its official API.

(a) A residual FETCH FIRST bug in CockroachDB (Bug #171238).
(b) A residual domain-validation bug in CockroachDB (Bug #173599).
(c) A residual hint-preservation bug in MariaDB (Bug #39946).
Fig. 6. Representative sibling bugs discovered by REAPER. Each column compares a repaired historical query with its sibling test that exposes a residual bug.
4.1.2 Target Databases. We evaluate REAPER on four production-grade relational DBMSs: MySQL (v9.6.0), MariaDB (v13.2), OceanBase (v4.5.1), and CockroachDB (v26.3.0). The selected systems cover both centralized and distributed architectures and differ in their SQL grammar and execution implementations, allowing us to evaluate REAPER across heterogeneous DBMS designs. The coverage comparison is conducted on MySQL, MariaDB, and OceanBase. CockroachDB is excluded because its branch coverage could not be measured under the same instrumentation setup.
4.1.3 Baselines. We compare REAPER against three state-of-the-art DBMS testing approaches: SQLancer [22–24], Squirrel [29], and Argus [16]. These baselines represent complementary strategies for DBMS testing, including generation-based testing, structure-aware mutation, and LLM-assisted oracle discovery and test generation. SQLancer generates queries from scratch and detects logic bugs using DBMS testing oracles such as TLP [23] and NoREC [22]. In our experiments, we use TLP for MySQL and NoREC for the remaining DBMS targets. Squirrel is a mutation-based fuzzer that translates seed queries into an intermediate representation and applies structure-aware mutations to explore new execution paths. Argus uses LLMs to propose pairs of equivalent Constrained Abstract Queries (CAQs), verifies their equivalence using a SQL equivalence solver, and instantiated the verified pairs with reusable SQL snippets to generate concrete test cases [16].
4.1.4 Historical Bug Corpus. To construct the historical bug corpus, we mine bug-fixing commits from the GitHub repositories of the four target DBMSs and retain commits for which the artifacts required by Bug Profile Construction can be recovered. For each retained commit, we extract the associated description, regression test, and code patch. In total, this collection stage yields 4,487 historical bug-fixing commits: 1,713 from MySQL, 1,139 from OceanBase, 1,112 from MariaDB, and 523 from CockroachDB. These commits form the input corpus for Bug Profile Construction.
4.2 RQ1: Effectiveness in Sibling-Bug Discovery
Overall results. REAPER discovered 61 previously unknown sibling bugs across the four evaluated DBMSs: 23 in MariaDB, 15 in MySQL, 9 in OceanBase, and 14 in CockroachDB. As summarized in Table 1, 57 bugs have been confirmed by upstream developers, of which 13 have already been fixed, while the remaining 4 are still under analysis. Notably, a single historical fix can expose residual bugs in multiple sibling handlers. For example, starting from the historical fix for NEXTVAL, REAPER

Fig. 7. The distribution of unique bugs detected by REAPER and the baselines.
exposed the same residual issue in both LASTVAL and SETVAL. We conservatively consolidate such manifestations when they correspond to the same underlying bug, so they are counted as one sibling bug rather than multiple discoveries. Hence, the 61 bugs represent distinct reported bugs, while the affected sibling handlers and triggering tests are more numerous, demonstrating that REAPER can extend a localized historical fix to systematically uncover unpatched behavior across its sibling handlers. Beyond the reported bugs, REAPER extends each historical regression test from the repaired construct to its grammar-defined sibling set. Under the recovered bug-triggering context, the generated sibling tests enable systematic validation of the related sibling handlers for the same historical bug. This turns a regression test for a single repaired construct into a sibling-level regression task, allowing the original test and its generated sibling tests to be executed together in existing regression-testing and CI workflows.
Bug Significance and Impact. The reported bugs span silently incorrect results, crashes, and fatal internal errors. Their upstream severity assessments and subsequent fixes further indicate their practical impact. All 15 MySQL bugs listed in Table 1 carry Oracle's S3 severity rating, while most confirmed MariaDB bugs were rated major. Thirteen bugs have already been patched upstream.
MariaDB Bug #39063 provides a representative example of a sibling bug. The historical bug affected NEXTVAL, where the corresponding repair introduced a table_list->is_pure_alias() check. REAPER subsequently exposed the same missing handling in the LASTVAL and SETVAL sibling handlers. MariaDB upgraded the report from major to critical, and the developer explicitly referred to the historical NEXTVAL repair when suggesting the fix: "try adding the table_list->is_pure_alias() block to Item_func_setval::val_int, same as Item_func_nextval::val_int? Add a test case appended to where the previous fix was and create a pull request."
Cross-version reproduction further indicates that some sibling bugs remain present across multiple maintained releases. For Bug #39598, a MariaDB developer reproduced the issue on four versions: "I could reproduce the issue with testcase provided in report on mariadb 10.11, 11.4, 11.8 and 12.3... This inconsistency occurs in the error path and can break tools or scripts that expect a uniform format in the Table column. Attached the mtr test to repro." Notably, MariaDB 10.11 became generally available in February 2023, showing that the issue remained present across release lines spanning more than three years.
Several reports also received rapid upstream responses. For CockroachDB Bug #171234, the developer took ownership of the report on the day of disclosure and identified the missing guard in both width_bucket overloads: "Taking this up. The guard is missing from both the numeric and int overloads of width_bucket in pkg/sql/sem/builtins/math_builtins.go. Will open a draft PR shortly." An upstream fix was submitted on the following day.
Bug Diversity. The 61 sibling bugs cover a broad range of failure manifestations and DBMS components. Among them, 50 are logic bugs that complete execution but manifest in diverse forms of incorrect behavior, while the remaining 11 result in crashes or fatal internal errors. These bugs arise across multiple stages of DBMS processing, including query analysis, optimization, temporary-table processing, execution, and built-in routines. To better illustrate the diversity of these sibling bugs, we present three representative cases showcasing the different implementation locations and validation conditions encountered by REAPER. Specifically, the selected cases span cursor handling, datetime construction, and hint preservation across different DBMS components and failure manifestations.
Implementation-location diversity. The three cases show how a historical regression test can leave related handlers untested across different implementation structures. In Figure 6(a), FETCH ABSOLUTE and FETCH FIRST reach separate cursor-dispatch branches. Discovering the residual bug requires changing the cursor operation while retaining the empty-table, WITH HOLD, and cross-transaction conditions. Grammar-Guided Sibling Mutation performs this localized substitution, directing the historical trigger to the sibling branch that lacks the check. In Figure 6(b), the missing validation occurs in a different built-in routine: make_timestamp accepts an out-of-domain calendar component even though the historical fix corrected such handling in make_date. Here, sibling selection identifies the target routine, while Trigger-Constrained Concretization supplies its additional time arguments without removing the bug-triggering condition. In Figure 6(c), the two hints follow different handling paths during view creation. The Concretizer supplies the time limit and delay needed to exercise MAX_EXECUTION_TIME, while retaining the historical view-creation context. Across these cases, the syntactic-sibling relation determines which alternative handler to test, and the trigger profile constrains the sibling tests to retain the conditions relevant to the bug.
Validation-condition diversity. The contrast among the three cases illustrates why direct differential comparison with the historical execution result is insufficient for validating sibling bugs. In Figure 6(a), the sibling exposes an internal error under the preserved bug-triggering conditions, allowing Stage I to associate the execution with the historical bug through . The other two cases are more subtle because the sibling executions complete successfully. In Figure 6(b), the concrete input changes from year=0 to month=13, and make_timestamp naturally produces a different form of result from make_date. Comparing their concrete outputs would therefore provide no useful oracle. Instead, Stage II establishes that also applies to the sibling, while Stage III uses to determine that returning a normalized timestamp for an out-of-domain calendar component is incorrect. A similar issue appears in Figure 6(c): NO_INDEX and MAX_EXECUTION_TIME have different semantics, so their execution results are not expected to be identical. Reaper instead checks whether applies to the sibling hint and then uses to determine whether the hint is preserved and takes effect. These cases show that the staged validation does not require a sibling test to reproduce the historical execution result; it uses the Validation Profile to determine whether the sibling execution represents the same bug under its own semantics.
4.3 RQ2: Baseline Comparison
To assess the effectiveness of REAPER, we compare it with three state-of-the-art DBMS testing methods: SQLANCER, SQUIRREL, and ARGUS. These baselines represent complementary testing paradigms, including query generation, mutation-based exploration, and LLM-guided test synthesis. Each tool runs for 8 hours per target DBMS on identical hardware, using the same seeds when required and its default configuration without additional tuning. We measure bug-finding effectiveness by the number of unique bugs discovered in the controlled comparison. We additionally record branch coverage as well as syntactic and semantic validity to characterize the explored execution space.
Bug-Finding Capability. Figure 7 summarizes the unique bugs discovered in the controlled comparison. REAPER discovers 38 bugs, compared with 7 for SQLANCER, 1 for ARGUS, and none for SQUIRREL, with no overlap between REAPER and the baselines. The key distinction lies in the defect space targeted by each approach. Existing approaches explore a general SQL input space through generation or mutation, whereas REAPER replaces the historical bug-triggering construct

(a) MySQL

(b) MariaDB

(c) OceanBase
Fig. 8. Code branch coverage (k) on MySQL, MariaDB, and OceanBase.

(a) Syntactic validity

(b) Semantic validity
Fig. 9. Syntactic and semantic validity of generated sibling tests.
with its syntactic siblings while preserving the associated bug-triggering context. Consequently, its search is concentrated on handlers that are structurally related to a repaired path but may not have received the same fix. This Bug-Profile-guided sibling testing exposes residual inconsistencies that general-purpose generation and mutation do not explicitly target.
Code Coverage. Figure 8 shows branch-coverage growth on MySQL, MariaDB, and OceanBase over the 8-hour campaigns. We exclude CockroachDB due to the instrumentation limitation discussed in Section 4.1. REAPER achieves higher branch coverage than all baselines on all three systems throughout each campaign and finishes at approximately 151K, 98K, and 274K branches on MySQL, MariaDB, and OceanBase, respectively.
By comparison, the strongest baseline ARGUS reaches 133K, 86K, and 222K; SQLANCER reaches 118K, 76K, and 197K; and SQUIRREL reaches 65K, 63K, and 165K. Relative to the strongest baseline on each system, these final coverage values correspond to gains of 13.5%, 14.0%, and 23.4%. The additional coverage reached by REAPER reflects its ability to traverse implementation paths associated with repaired constructs and their syntactic siblings. These paths are not merely uncovered SQL features; they represent alternative handlers that may share the repaired requirement but evolve inconsistently during maintenance.
Manual inspection of the final coverage profiles further shows that REAPER's coverage is complementary to, rather than a strict superset of, the baselines'. While some regions covered by the baselines remain uncovered by REAPER, it also reaches branches that none of them exercise. The key difference lies in the dimension along which execution paths are explored: instead of broadly exploring the SQL input space, REAPER replaces the historical construct with its syntactic siblings while preserving the associated bug-triggering context. This changes the exercised handler without discarding the context implicated in the historical bug. As a result, sibling mutation reaches additional implementation paths in components such as optimization, expression resolution, and statement preparation, explaining the complementary coverage observed in the profiles.
Table 2. Ablation study: unique bugs discovered by each REAPER configuration.
| DBMS | REAPER | REAPER- | REAPER- |
|---|---|---|---|
| MariaDB | 12 | 0 | 2 |
| MySQL | 7 | 0 | 0 |
| OceanBase | 9 | 0 | 1 |
| CockroachDB | 10 | 1 | 2 |
| Total | 38 | 1 | 5 |
Table 3. Ablation of sibling-bug validation on the curated benchmark.
| Configuration | Acc. | Prec. | Rec. | F1 |
|---|---|---|---|---|
| LLM-only | 46.9 | 38.2 | 72.2 | 50.0 |
| Historical Diff + LLM | 61.2 | 48.6 | 94.4 | 64.2 |
| + Stage I (match ) | 75.5 | 61.5 | 88.9 | 72.7 |
| + Stage II (apply ) | 81.6 | 69.6 | 88.9 | 78.0 |
| Full REAPER (+ ) | 87.8 | 80.0 | 88.9 | 84.2 |
SQL Validity. Reaching deeper DBMS logic requires generated queries to remain valid beyond parsing. Figure 9 reports the syntactic validity across the four evaluated DBMSs and the semantic validity on MySQL, MariaDB, and OceanBase. REAPER maintains consistently high syntactic validity, reaching 98% on MySQL and MariaDB and 97% on OceanBase and CockroachDB. SQLANCER and ARGUS are slightly higher at 98–99%. The small gap mainly arises from the additional concretization performed by REAPER: although sibling statement skeletons are derived from the DBMS grammar, completing sibling-specific operands and context can occasionally produce queries rejected by the parser. More importantly, REAPER achieves substantially higher semantic validity, reaching 87%, 86%, and 88% on MySQL, MariaDB, and OceanBase, respectively, compared with approximately 73% for SQLANCER and 43–63% for ARGUS. Mutation-based SQUIRREL achieves syntactic validity of 73%, 84%, and 66% and semantic validity of 15–26% on the three supported DBMSs. These results show that the modest syntactic cost introduced by concretization is accompanied by a substantial gain in semantic validity. By incorporating the historical query context, the Concretizer resolves sibling-specific bindings and operands while preserving the grammar-defined sibling structure, allowing more generated tests to exercise the intended sibling handlers.
In summary, REAPER demonstrates stronger bug-finding capability than the baselines, while also achieving higher branch coverage and semantic validity with comparable syntactic validity. These results adequately answer RQ2.
4.4 RQ3: Ablation Study
We examine the two key components that enable sibling-bug discovery in REAPER: the identification of the bug-triggering construct , which guides grammar-guided sibling mutation, and trigger-constrained concretization, which resolves sibling-specific semantic requirements while preserving the bug-triggering context recovered from historical fixes. We compare full REAPER against REAPER-, which replaces the identified bug-triggering construct with a randomly selected mutable construct, and REAPER-, which removes the concretizer. All configurations use the same historical corpus, target DBMSs, and validation procedure. We evaluate the contribution of sibling bug validation separately in §4.5.
Bug-triggering construct . The effectiveness of sibling test generation depends first on whether the bug-triggering construct can be identified reliably. As a direct LLM baseline, we provide the complete historical fix to a single LLM and ask it to identify in one pass; this achieves only 63.0% accuracy. In contrast, REAPER analyzes the fix from complementary query-side and repair-side views. The Query Analyzer and Patch Analyzer initially agree on 78.1% of the fixes, and the Orchestrator resolves disagreements for another 14.2%, while the remaining 7.7% are discarded when the two views remain inconsistent. Two authors independently inspected a random sample of 50 accepted Bug Profiles and judged the confirmed correct in 94.0% of them. These results show that cross-view analysis provides a substantially more reliable anchor for subsequent sibling testing while filtering localizations that cannot be consistently established.
The ablation further shows why identifying is important. As shown in Table 2, REAPER- reduces the number of detected bugs from 38 to 1, with no bug found on MariaDB, MySQL, or OceanBase. Importantly, this variant still performs the same sibling mutation, concretization, and validation; the only difference is the construct selected for mutation. This result demonstrates that syntactic relatedness alone is insufficient for identifying defect-relevant sibling handlers. The historical fix provides the semantic context that connects syntactic siblings with the repaired behavior. Without this repair context, mutation may reach syntactically similar handlers but lacks evidence that these handlers are subject to the same repaired requirement.
Trigger-constrained concretization. REAPER- retains the same and therefore the same defect-relevant sibling candidates, but exposes only 5 bugs compared with 38 for full REAPER. This contrast separates structural relevance from executable activation. Grammar-Guided Sibling Mutation can identify a related handler and construct a corresponding skeleton, but the selected sibling may introduce new operands, bindings, or execution requirements that are absent from the historical query. Without concretization, many such skeletons fail before the behavior of the selected sibling is exercised. Hence, grammar relations determine where to test, but do not by themselves provide the semantic conditions required to exercise the target handler.
Taken together, the two ablations reveal a division of responsibility in REAPER's test generation. Identifying the bug-triggering construct concentrates the search on defect-relevant sibling handlers, whereas trigger-constrained concretization enables those handlers to be exercised under a realizable test context. Removing either property substantially degrades bug discovery, showing that sibling testing requires both a bug-relevant target and a semantically valid sibling test.
4.5 RQ4: Effectiveness of Logic-Bug Validation
To evaluate REAPER's logic-bug validation capability, we examine how reliably it distinguishes sibling-bug candidates.
Curated validation benchmark. We construct a labeled benchmark to isolate the effectiveness of the three-stage validation in Section 3.3. The benchmark is not intended to estimate field precision; instead, it provides a fixed set on which different validation strategies can be compared under identical candidates. It contains upstream-confirmed sibling bugs, triaged logic candidates, controlled oracle-replay cases, and manually labeled benign projections. Each record contains the Bug Profile , the sibling query , its execution outcome, and a human label. Crash and fatal-error candidates are excluded because this experiment focuses on logic-bug validation. In total, the benchmark contains 49 logic candidates, including 18 positives and 31 negatives (test cases show different but correct behavior from the fixed historical bug).
Staged validation effectiveness. Table 3 compares configurations that progressively incorporate historical execution information and the three components of the Validation Profile: , the historical failure pattern; , the fix-derived criterion specifying expected SQL behavior; and , the fix-derived oracle specifying a checkable condition or relation under the conditions specified in the oracle. LLM-only, which classifies candidates using their execution outputs alone, achieves 46.9% accuracy, 38.2% precision, 72.2% recall, and 50.0% F1, misclassifying 21 of the 31 benign projections as bugs. Historical Diff + LLM additionally incorporates the historical and sibling execution outcomes, increasing recall to 94.4% and precision to 48.6%. It retains 17 of the 18 positive cases but still produces 18 false positives, indicating limited discrimination between sibling bugs and legitimate execution differences. Adding Stage I (match ) requires the sibling execution to exhibit the historical failure pattern. False positives decrease from 18 to 10, increasing precision to 61.5% and accuracy to 75.5%. Recall decreases from 94.4% to 88.9%, corresponding to one fewer retained positive case (17 to 16). The higher recall results from this relatively permissive decision, which preserves nearly all positive cases while also admitting many benign projections. Adding Stage II (apply ) checks whether the fix-derived criterion applies to the selected sibling. This further reduces false positives to 7 and increases precision to 69.6% and accuracy to 81.6%, while recall remains at 88.9%. Full REAPER additionally evaluates oracle violation using under the conditions specified in the oracle, reducing false positives to 4 and achieving 87.8% accuracy, 80.0% precision, 88.9% recall, and 84.2% F1. It retains 16 of the 18 positive cases and correctly rejects 27 of the 31 benign projections. Following failure-pattern matching, criterion-applicability and oracle-violation checking together increase precision from 61.5% to 80.0% without reducing recall. These results support the contribution of the validation profile to rejecting benign projections while retaining true sibling bugs.
5 Related Work
DBMS Fuzzing. DBMS fuzzing has been extensively studied for discovering bugs through automated SQL generation and mutation. Mutation-based fuzzers, including Squirrel [29], DynSQL [7], and SQLRight [13], evolve existing SQL seeds through AST-level, stateful, or coverage-guided transformations. Generation-based approaches, such as SQLsmith [18], Polyglot [2], and SQLancer++ [31], synthesize SQL queries from grammars or adaptive generators. Other approaches introduce additional guidance through grammar-free testing, reusable semantic operations, query-plan exploration, coverage-guided traversal, and bug-pattern prioritization [1,4,12,28,29].
Recent DBMS testing approaches have also adopted LLMs to assist SQL generation. ShQvel [30] synthesizes SQL fragments to improve dialect coverage, while Argus [16] generates constrained abstract query pairs together with oracle templates. These approaches improve the diversity and complexity of generated SQL inputs, but primarily explore the general DBMS input space. They do not identify a bug-triggering construct from a historical fix and extend its triggering context to grammar-related sibling handlers. REAPER instead starts from a historical fix, recovers its Bug Profile, and uses the bug-triggering construct to direct testing toward sibling handlers that may contain residual sibling bugs.
Test Oracles for DBMS Testing. Reliable DBMS testing requires effective oracles for determining whether an execution is incorrect. Metamorphic testing approaches, such as TLP [23] and NoREC [22], construct logically related query variants to detect inconsistent results. Differential execution approaches, including DQE [26], compare multiple executions under related inputs, while EET [8] and CODDTest [28] exploit expression-level equivalences. PINOLO [5] synthesizes approximate metamorphic relations, and Kangaroo [9] combines context-sensitive instantiation with multi-plan execution. Other approaches derive test oracles from configuration changes [10], cross-engine agreement [4], or executable SQL semantics [15]. These oracle mechanisms rely on predefined relations or specifications, such as semantic equivalence, differential consistency, configuration invariance, cross-engine agreement, or reference semantics. However, they cannot be directly applied to Sibling Bug Validation because execution differences between sibling and historical tests do not necessarily indicate a bug.
REAPER instead derives the Validation Profile from the historical fix. captures the historical failure pattern, provides the fix-derived oracle, and provides the fix-derived criterion. During Sibling Bug Validation, these three components guide the LLM-based validation of whether the historical failure pattern is present, whether the fix-derived criterion applies to the selected sibling, and whether the observed behavior violates the fix-derived oracle.
6 Conclusion
In this paper, we identified sibling bugs, residual DBMS defects that persist in handlers corresponding to syntactic siblings after a localized fix. We presented REAPER, a fix-anchored DBMS fuzzing framework that reuses historical fixes to extend regression testing beyond the originally repaired path. REAPER recovers Trigger Profile and Validation Profile from historical fixes, projects bug-triggering queries to syntactic siblings defined by the SQL grammar, and validates sibling executions using fix-derived evidence. Evaluated on MariaDB, MySQL, OceanBase, and CockroachDB, REAPER uncovered 61 previously unknown bugs, of which 57 have been confirmed and 13 have been fixed by developers. These results show that historical fixes can serve as reusable testing knowledge for systematically exposing residual defects across handlers corresponding to syntactic siblings.
7 Data Availability
The source code and original evaluation data are hosted anonymously on Figshare: https://figshare.com/s/a9aab4d572fb108f7ba7.
References
[1] Jinsheng Ba and Manuel Rigger. 2023. Testing database engines via query plan guidance. In 2023 IEEE/ACM 45th International Conference on Software Engineering (ICSE). IEEE, 2060–2071.
[2] Yongheng Chen, Rui Zhong, Hong Hu, Hangfan Zhang, Yupeng Yang, Dinghao Wu, and Wenke Lee. 2021. One engine to fuzz'em all: Generic language processor testing with semantic validation. In 2021 IEEE Symposium on Security and Privacy (SP). IEEE, 642–658.
[3] Cockroach Labs 2026. CockroachDB Documentation. Cockroach Labs. Accessed: 2026-10-01. https://www.cockroachlabs.com/docs/
[4] Ying Fu, Zhiyong Wu, Yuanliang Zhang, Jie Liang, Jingzhou Fu, Yu Jiang, Shanshan Li, and Xiangke Liao. 2025. Thanos: DBMS Bug Detection via Storage Engine Rotation Based Differential Testing. In 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE). 655–666. doi:10.1109/ICSE55347.2025.00001
[5] Zongyin Hao, Quanfeng Huang, Chengpeng Wang, Jianfeng Wang, Yushan Zhang, Rongxin Wu, and Charles Zhang. 2023. Pinolo: Detecting logical bugs in database management systems with approximate query synthesis. In 2023 USENIX annual technical conference (USENIX ATC 23). 345–358.
[6] ISO/IEC. 2016. Information Technology – Database Languages – SQL – Part 2: Foundation (SQL/Foundation). International Organization for Standardization, Geneva, Switzerland.
[7] Zu-Ming Jiang, Jia-Ju Bai, and Zhendong Su. 2023. DynSQL: Stateful fuzzing for database management systems with complex and valid SQL query generation. In 32nd USENIX Security Symposium (USENIX Security 23). 4949–4965.
[8] Zu-Ming Jiang and Zhendong Su. 2024. Detecting logic bugs in database engines via equivalent expression transformation. In 18th USENIX Symposium on operating systems design and implementation (OSDI 24). 821–835.
[9] Jiaqi Li, Ke Wang, Yaoguang Chen, Yajin Zhou, Lei Wu, and Jiashui Wang. 2025. Detecting DBMS bugs with context-sensitive instantiation and multi-plan execution. Computers & Security 157 (2025), 104564.
[10] Jie Liang, Zhiyong Wu, Jingzhou Fu, Mingzhe Wang, Chengnian Sun, and Yu Jiang. 2024. Mozi: Discovering dbms bugs via configuration-based equivalent transformation. In Proceedings of the IEEE/ACM 46th International Conference on Software Engineering. 1–12.
[11] Yu Liang and Hong Hu. 2025. Parser Knows Best: Testing DBMS with Coverage-Guided Grammar-Rule Traversal. arXiv preprint arXiv:2503.03893 (2025).
[12] Yu Liang and Peng Liu. 2026. Efficiently Detecting DBMS Bugs through Bottom-up Syntax-based SQL Generation. In NDSS.
[13] Yu Liang, Song Liu, and Hong Hu. 2022. Detecting logical bugs of DBMS with coverage-based guidance. In 31st USENIX Security Symposium (USENIX Security 22). 4309–4326.
[14] Li Lin, Liehang Chen, and Rongxin Wu. 2026. ValScope: Value-Semantics-Aware Metamorphic Testing for Detecting Logical Bugs in DBMSs. In 20th USENIX Symposium on Operating Systems Design and Implementation (OSDI 26). USENIX Association, Seattle, WA, 387–403. https://www.usenix.org/conference/osdi26/presentation/lin-li
[15] Shuang Liu, Chenglin Tian, Jun Sun, Ruifeng Wang, Wei Lu, Yongxin Zhao, Yinxing Xue, Junjie Wang, and Xiaoyong Du. 2024. Semantic Conformance Testing of Relational DBMS. Proceedings of the VLDB Endowment 18, 3 (2024), 850–862.
[16] Qiuyang Mang, Runyuan He, Suyang Zhong, Xiaoxuan Liu, Huanchen Zhang, and Alvin Cheung. 2026. Automated Discovery of Test Oracles for Database Management Systems Using LLMs. Proc. ACM Manag. Data 4, 3, Article 140 (May 2026), 28 pages. doi:10.1145/3802017
[17] MariaDB Corporation 2026. MariaDB Documentation. MariaDB Corporation. Accessed: 2026-10-01. https://mariadb.com/kb/en/
[18] Andreas Neumann. 2026. SQLSmith: Random SQL Query Generator for Testing DBMS. https://github.com/anse1/sqlsmith. Accessed: 2026-05-19.
[19] OceanBase 2026. OceanBase Documentation. OceanBase. Accessed: 2026-10-01. https://www.oceanbase.com/docs
[20] Oracle Corporation 2026. MySQL 8.4 Reference Manual. Oracle Corporation. Accessed: 2026-10-01. https://dev.mysql.com/doc/refman/8.4/en/
[21] Mark Raasveldt and Hannes Mühleisen. 2019. Duckdb: an embeddable analytical database. In Proceedings of the 2019 international conference on management of data. 1981–1984.
[22] Manuel Rigger and Zhendong Su. 2020. Detecting optimization bugs in database engines via non-optimizing reference engine construction. In Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering. 1140–1152.
[23] Manuel Rigger and Zhendong Su. 2020. Finding bugs in database systems via query partitioning. Proceedings of the ACM on Programming Languages 4, OOPSLA (2020), 1–30.
[24] Manuel Rigger and Zhendong Su. 2020. Testing database engines via pivoted query synthesis. In 14th USENIX Symposium on Operating Systems Design and Implementation (OSDI 20). 667–682.
[25] Yankai Rong, Shuang Liu, Jinhao Dong, Qiang Yin, Wei Lu, Jianhua Wang, and Xiaoyong Du. 2026. DBcover: A White-box SQL Test Generation Framework for Coverage Improvement. In Proceedings of the 2026 IEEE/ACM 48th International Conference on Software Engineering (ICSE-Companion '26). Association for Computing Machinery, New York, NY, USA, 367–378. doi:10.1145/3774748.3793626
[26] Jiansen Song, Wensheng Dou, Ziyu Cui, Qianwang Dai, Wei Wang, Jun Wei, Hua Zhong, and Tao Huang. 2023. Testing database systems via differential query execution. In 2023 IEEE/ACM 45th International conference on software engineering (ICSE). IEEE, 2072–2084.
[27] Jin Wei, Ping Chen, Kangjie Lu, Jun Dai, and Xiaoyan Sun. 2026. SQLaser: Detecting database management system (DBMS) logic bugs with clause-guided fuzzing. Journal of Computer Security 34, 1 (2026), 3–28.
[28] Chi Zhang and Manuel Rigger. 2025. Constant optimization driven database system testing. Proceedings of the ACM on Management of Data 3, 1 (2025), 1–24.
[29] Rui Zhong, Yongheng Chen, Hong Hu, Hangfan Zhang, Wenke Lee, and Dinghao Wu. 2020. Squirrel: Testing database management systems with language validity and coverage feedback. In Proceedings of the 2020 ACM SIGSAC Conference on Computer and Communications Security. 955–970.
[30] Suyang Zhong and Manuel Rigger. 2025. Testing Database Systems with Large Language Model Synthesized Fragments. arXiv preprint arXiv:2505.02012 (2025).
[31] Suyang Zhong and Manuel Rigger. 2026. Scaling Automated Database System Testing. In Proceedings of the 31st ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 2. 1677–1692.