arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.23294cs.DBcs.SE
收藏

一种基于集合论的数据库管理系统内连接优化逻辑错误检测方法

A Set-Theoretic Approach to Detecting Logic Bugs in DBMS Inner Join Optimizations

East China Normal University(华东师范大学);Digital Technologies, Ant Group(蚂蚁集团数字技术);Tsinghua University(清华大学)

Ce Lyu, Changzheng Wei, Yanhao Wang, Jie Liang, Li Lin, Hanghang Wu, Minghao Zhao, Ying Yan, Aoying Zhou

AI总结:

提出基于集合论的蜕变测试方法,通过交集运算和三种语义保持变换规则生成等价查询,比较结果发现DBMS优化器逻辑错误,在主流系统中发现29个新问题。

摘要:

查询优化器是数据库管理系统的基本组件,通过评估备选查询计划来确定给定查询的最高效执行策略。在其任务中,连接优化起着核心作用,因为多表查询中连接的顺序会显著影响执行性能。然而,由于连接优化固有的复杂性,逻辑错误不可避免且难以检测。尽管现有的模糊测试工具在发现崩溃和性能相关错误方面取得了显著成功,但有效识别逻辑错误(即系统产生不正确查询结果的情况)仍未解决。在本文中,我们提出了一种蜕变测试方法,通过集合论的视角检测与内连接优化相关的DBMS错误。对于每个测试用例,基于基本集合操作——交集——生成等价查询,并引入三种语义保持变换规则,即对称连接变换、非对称差变换和对称差变换。这些规则将简单的NATURAL/INNER JOIN查询重写为更复杂但语义等价的形式。我们将此设计实现为JoinEquiv,通过比较原始查询和变换查询的结果,作为测试预言机,系统地揭示DBMS查询处理中的逻辑不一致性。使用JoinEquiv,我们在主流DBMS(MySQL、TiDB、DuckDB和Percona)中发现了29个先前未知的问题,其中27个已得到官方确认。JoinEquiv揭示了DBMS优化器和执行器中的深层逻辑缺陷,突显了其在增强DBMS健壮性方面的价值。

英文摘要:

The query optimizer is a fundamental component of database management systems that determines the most efficient execution strategy for a given query by evaluating alternative query plans. Among its tasks, join optimization plays a central role, as the order of joins in multi-table queries can significantly affect execution performance. However, due to the inherent complexity of join optimization, logical bugs are inevitable and often difficult to detect. While existing fuzzing tools have shown notable success in uncovering crash- and performance-related errors, effectively identifying logical bugs -- cases in which the system produces incorrect query results -- remains largely unresolved. In this paper, we propose a metamorphic testing approach to detect DBMS bugs related to INNER JOIN optimization through the lens of set theory. For each testing case, equivalent queries are generated based on a basic set operation -- intersection -- and three semantics-preserving transformation rules, i.e., symmetric join transformation, asymmetric difference transformation, and symmetric difference transformation, are introduced. These rules rewrite a simple NATURAL/INNER JOIN query into a more complex, yet semantically equivalent, form. We implement this design in JoinEquiv, which serves as a testing oracle to systematically uncover logical inconsistencies in DBMS query processing by comparing the results of original and transformed queries. Using JoinEquiv, we uncovered 29 previously unknown issues in mainstream DBMSs (MySQL, TiDB, DuckDB, and Percona), and 27 of them were officially confirmed. JoinEquiv reveals deep logical flaws in DBMS optimizers and executors, underscoring its value in enhancing DBMS robustness.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑