论文标题
通过非优化参考引擎构建检测数据库引擎中的优化错误
Detecting Optimization Bugs in Database Engines via Non-Optimizing Reference Engine Construction
论文作者
论文摘要
数据库管理系统(DBMS)普遍使用。为了有效访问数据,它们采用了复杂的优化。错误的优化可能导致逻辑错误,这会导致查询计算不正确的结果集。我们提出了非优化参考引擎构建(NOREC),这是一种完全自动的方法,可以检测DBMS中的优化错误。从概念上讲,这种方法旨在通过优化和不优化的DBMS来评估查询,然后检测其返回结果集的差异,这将指示DBMS中的错误。获得DBM的非优化版本是具有挑战性的,因为DBM通常提供对优化的有限控制。我们的核心洞察力是,可以将可能随机生成的优化查询重写为DBMS无法优化的一个。评估此不优化的查询有效地对应于执行原始查询的非优化参考引擎。我们在四个广泛使用的DBM的广泛测试活动中对Norec进行了评估,即PostgreSQL,Mariadb,Sqlite和CockroachdB。我们在这些系统的最新版本中发现了159个以前未知的错误,其中141个由开发人员修复。其中51个是优化错误,而其余的是错误和崩溃错误。我们的结果表明,Norec是有效的,一般的,几乎不需要实施工作,这使得该技术在实践中广泛适用。
Database Management Systems (DBMS) are used ubiquitously. To efficiently access data, they apply sophisticated optimizations. Incorrect optimizations can result in logic bugs, which cause a query to compute an incorrect result set. We propose Non-Optimizing Reference Engine Construction (NoREC), a fully-automatic approach to detect optimization bugs in DBMS. Conceptually, this approach aims to evaluate a query by an optimizing and a non-optimizing version of a DBMS, to then detect differences in their returned result set, which would indicate a bug in the DBMS. Obtaining a non-optimizing version of a DBMS is challenging, because DBMS typically provide limited control over optimizations. Our core insight is that a given, potentially randomly-generated optimized query can be rewritten to one that the DBMS cannot optimize. Evaluating this unoptimized query effectively corresponds to a non-optimizing reference engine executing the original query. We evaluated NoREC in an extensive testing campaign on four widely-used DBMS, namely PostgreSQL, MariaDB, SQLite, and CockroachDB. We found 159 previously unknown bugs in the latest versions of these systems, 141 of which have been fixed by the developers. Of these, 51 were optimization bugs, while the remaining were error and crash bugs. Our results suggest that NoREC is effective, general and requires little implementation effort, which makes the technique widely applicable in practice.