通过查询计划引导测试数据库引擎
Testing Database Engines via Query Plan Guidance
AI总结:
提出查询计划引导(QPG)方法,通过变异数据库状态生成多样查询计划,引导自动化测试发现数据库引擎逻辑错误,在SQLite、TiDB和CockroachDB中发现53个新错误,效率显著高于随机和覆盖率引导方法。
摘要:
数据库系统被广泛用于存储和查询数据。已有研究提出了测试预言(test oracle)来发现此类系统中的逻辑错误,即导致数据库系统计算出不正确结果的错误。为了实现全自动化的测试方法,此类测试预言与测试用例生成技术配对使用;测试用例指数据库状态及可在其上应用测试预言的查询。在本工作中,我们提出了查询计划引导(Query Plan Guidance, QPG)的概念,用于将自动化测试引导至“有趣”的测试用例。SQL和其他查询语言是声明式的。因此,为了执行查询,数据库系统会将源语言中的每个操作符转换为可执行的众多所谓物理操作符之一;物理操作符的树被称为查询计划。我们的直觉是,通过将测试引导至探索多样的查询计划,我们也能探索更多有趣的行为——其中一些可能是错误的。为此,我们提出了一种变异技术,该技术逐步对数据库状态应用有前景的变异,从而使数据库管理系统为后续查询生成多样的查询计划。我们将我们的方法应用于三个成熟、广泛使用且经过大量测试的数据库系统——SQLite、TiDB和CockroachDB——并发现了53个独特的、先前未知的错误。我们的方法比朴素随机生成方法多执行了4.85-408.48倍的独特查询计划,比代码覆盖率引导方法多执行了7.46倍。由于大多数数据库系统(包括商业系统)向用户展示查询计划,我们认为QPG是一种普遍适用的黑盒方法,并相信其核心思想也可应用于其他场景(例如,衡量测试套件的质量)。
英文摘要:
Database systems are widely used to store and query data. Test oracles have been proposed to find logic bugs in such systems, that is, bugs that cause the database system to compute an incorrect result. To realize a fully automated testing approach, such test oracles are paired with a test case generation technique; a test case refers to a database state and a query on which the test oracle can be applied. In this work, we propose the concept of Query Plan Guidance (QPG) for guiding automated testing towards "interesting" test cases. SQL and other query languages are declarative. Thus, to execute a query, the database system translates every operator in the source language to one of potentially many so-called physical operators that can be executed; the tree of physical operators is referred to as the query plan. Our intuition is that by steering testing towards exploring diverse query plans, we also explore more interesting behaviors-some of which are potentially incorrect. To this end, we propose a mutation technique that gradually applies promising mutations to the database state, causing the DBMS to create diverse query plans for subsequent queries. We applied our method to three mature, widely-used, and extensively-tested database systems-SQLite, TiDB, and CockroachDB-and found 53 unique, previously unknown bugs. Our method exercises 4.85-408.48X more unique query plans than a naive random generation method and 7.46X more than a code coverage guidance method. Since most database systems-including commercial ones-expose query plans to the user, we consider QPG a generally applicable, black-box approach and believe that the core idea could also be applied in other contexts (e.g., to measure the quality of a test suite).
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。