Home / Companies / Cockroach Labs / Blog / Post Details
Content Deep Dive

Testing random, valid SQL in CockroachDB

Blog post from Cockroach Labs

Post Details
Company
Date Published
Author
Matt Jibson
Word Count
927
Company Posts That Month
1
Language
English
Hacker News Points
-
Post removed?
No
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.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.