Jorge Turbica / blog · Blog ← All articles ES · Leer en español
Cloud

The 0.001% bug: how a Hyperdrive cache returned empty MySQL rows

Hyperdrive for MySQL is GA; the empty-rows cache bug is a lesson in not caching client-specific bytes.

One in every 100,000 queries returned empty rows, and only with caching turned on. Cloudflare walked through the postmortem of that bug while announcing, on October 14, 2026, that Hyperdrive for MySQL is now generally available. A 0.001% failure never shows up in a test or an error-rate dashboard: you find out when a user gets an empty list that shouldn't be empty. And the lesson applies even if you never use Hyperdrive.

What Hyperdrive is and what GA brings

Hyperdrive is a distributed connection pooler that connects Workers to SQL databases: it keeps connections open and shares them across requests, which matters because opening a connection costs at least five network round trips. It can also cache common queries in the global CDN cache. Between the MySQL beta and GA there were "20 bug fixes", according to Cloudflare, and the goal during the beta was to validate 99.99% availability.

Each instance has two nodes. The Client runs next to the Worker, manages the local cache and forwards queries to the Endpoint, which keeps the pool close to the database. Both use their data center's CDN cache, so when they land in the same data center, they share a cache.

The bug

The Client cached the exact bytes it wrote to the Worker, already translated to that driver's capabilities, while the Endpoint always works with Hyperdrive's internal capabilities. The specific difference was CLIENT_DEPRECATE_EOF, which mysql2 doesn't support and which makes Hyperdrive rewrite the result set's EOF/OK packets. That opened two paths to failure:

  • If the Endpoint cached and the Client read, the Client replied to the Worker with untranslated Hyperdrive-format bytes.
  • If the Client cached and another node read, the result got translated twice and ended in a premature EOF or a hang.

The fix was to always store one canonical version of the result bytes, encoded with Hyperdrive's capabilities, no matter which node writes it. After the change the empty rows disappeared and the Client's connection success rate reached 99.99%.

Along the way, Cloudflare describes two MySQL traps: utf8 is a deprecated alias for utf8mb3 (1 to 3 bytes per character), so they moved to utf8mb4 to support emoji; and COM_RESET_CONNECTION resets the connection to the server's default charset, not the one negotiated in the handshake (for example latin1 instead of utf8mb4), so you have to set it again after every reset.

What you can learn from it

  • Cache content, not representation. If you store a response at an intermediate hop, the cache key has to include everything that shapes its encoding, or you store a canonical format. Storing "what I sent the client" mixes the two.
  • Rare failures need their own probes. A synthetic check for "this query should never come back empty" catches what an aggregate error rate never will.
  • Charset isn't a one-time setting. Any pool that resets connections has to set it again, and utf8 isn't full UTF-8.
  • GA numbers tell a story. Twenty fixes between beta and GA are an honest sign of maturity, and also a reminder that the rare case is the one that's hard to find.

If you run Workers with MySQL, the sensible test is to enable Hyperdrive with caching in staging and compare results against querying the database directly.

Sources

Jorge Turbica

Software Engineer and SRE. I write about the real challenges I run into in production.

See portfolio ↗