3
2 Comments

Fixed a 5-bug concurrency cascade in my SQLite-backed SDK — went from silent failures to 50 workers, 0 errors in under 5s

Building StreamCtx (open-source Python SDK for LLM agent observability) and spent the last few days chasing what I thought was one SQLite locking issue. Turned out to be five separate bugs stacked on top of each other.

The cascade, in the order I found them:

  1. WAL mode wasn't enabled — obvious first fix, but nowhere near enough on its own
  2. A storage "singleton" that wasn't actually being reused across connections — each call was silently opening a fresh one
  3. A connection leak: with self._connect() as conn: looks like it closes the connection, but sqlite3's context manager only manages the transaction, not the connection itself
  4. Reads and writes competing for the same connection pool under load
  5. Missing indexes on the column every query was filtering by

Fixed all five, then load tested with 50 concurrent workers. Before: sporadic failures under load. After: 50 workers, 0 errors, done in under 5 seconds — and I re-verified this on the actual published PyPI package, not just the local dev version, since I've been burned before by "works on my machine" claims in my own docs.

The annoying part: none of these bugs are exotic. Every one of them is "well known" if you already know to look for it. But the standard advice online stops at "enable WAL mode," which is necessary but not sufficient, and the docs don't really do a good job flagging the connection-closing gotcha.

Wrote up the honest before/after in the README rather than just claiming it's fixed — figured that's worth more than a badge.

Repo's open source if anyone wants to see the actual fix: github.com/streamctx/streamctx

on July 16, 2026
  1. 1

    The fixes are impressive, but the stronger insight is about trust. Observability tools don't earn adoption because they collect more telemetry—they earn it because developers believe the tool itself won't become another source of uncertainty. I'd keep validating whether StreamCtx's advantage is richer observability or engineering reliability people can confidently build production workflows around.

  2. 1

    Re-verifying the published PyPI package is the bit most fixes miss. I'd add one regression test that repeatedly creates and tears down the SDK from separate processes, because the fake singleton and context-manager leak are lifecycle bugs, not just load bugs. Fifty workers proves the steady state; install-and-restart cycles prove the boundary.

Trending on Indie Hackers
641 downloads, 2 sales, and I still don't know why User Avatar 131 comments I sent 43 cold emails with my own tool. 17 replied. 1 paid. Here’s the unofficial launch. User Avatar 95 comments I built for one user. Myself. User Avatar 67 comments My AI agent quoted a client a price we killed months ago. So I built Engram. User Avatar 34 comments Got our first paid customers from an unexpected channel User Avatar 28 comments I came up with a great idea for a solo Vibe Coding project, and I'm testing it out right now User Avatar 22 comments