Back to Blog

The Hallucinated Rows Incident

Ittai Dafner

Herein lies the tale of the serialization bug that caused one of the weirdest crashes in the company’s history- the infamous “Not enough values in db” panic. Delve with me into the depths of implementing but a single SQL operator- [.code]ORDER BY ... LIMIT[.code].

The Big Diff With Our Engine

At Epsio Labs, we develop an incremental SQL engine- in brief, an SQL engine that operates on changes in the data, instead of always using the whole dataset. Explaining why that’s useful I’ll leave to our documentation, but to understand this bug it is important you understand a little how our engine works.

The Epsio Engine represents data as a [.code]Diff[.code]- each [.code]Diff[.code] is a key-value pair, specifying a modification to the value of some specific key. Internally, we usually write a diff like so:[.code]"rock": +1[.code]. This diff can be read as "add one to the value of the string [.code]rock[.code]".

The important property of a diff is that diffs on equal keys can be consolidated together into one diff by adding their modifications together-consider for example this list of diffs:

"rock"      : +3 
"other_rock": +4 
"rock"      : -2

This list can be consolidated to a shorter one:

"rock"      : +1 
"other_rock": +4
This is some text inside of a div block.

Ready to get started?