Company
Date Published
Author
Matt Jibson
Word count
927
Language
English
Hacker News points
None

Summary

In an effort to identify and mitigate unintended behaviors in CockroachDB, a method was developed to test random SQL statements using the database's YACC-defined SQL grammar. This approach aims to generate valid SQL statements that can expose system vulnerabilities, such as crashes or excessive resource usage. Existing tools like sqllogictest and sqlsmith were found to be insufficient due to differences in SQL semantics and unsupported statements in CockroachDB. By converting the YACC grammar into an Abstract Syntax Tree (AST), a program was created to generate various SQL statements by replacing non-terminals with their possible branches, leading to the discovery of over a dozen unique panics and other issues. These tests, which also include random function call generation, have revealed significant bugs and prompted code refactoring, including a fix for a race condition. The testing is now conducted nightly to preemptively address new problems, and the process automatically incorporates new SQL syntax as it is added. The success of this testing approach supports the stability of CockroachDB, and the team is seeking new hires to contribute to building distributed SQL systems.