Files
core/bible-local/decisions/2026-03-01-mysql-tx-cursor-safety.md
2026-03-15 16:29:24 +03:00

1011 B

2026-03-01 - MySQL Tx Cursor Safety In Recompute/Rebuild Flows

  • Date: 2026-03-01
  • Decision:
    • In transactional MySQL/MariaDB code, prohibit nested SQL calls on the same tx while iterating an open cursor (for rows.Next()).
    • Use a mandatory two-phase approach: read all rows -> close cursor -> execute follow-up reads/writes.
  • Context:
    • History recompute/rebuild jobs produced persistent driver failures:
      • [mysql] invalid connection
      • unexpected EOF
      • driver: bad connection
    • DB logs showed repeated aborted client connections (Got an error reading communication packets).
    • Root cause pattern was SQL execution on the same transaction while a result cursor was still active.
  • Consequences:
    • Recompute/rebuild code paths must be audited and kept cursor-safe.
    • Future projection rebuild and repair flows must follow two-phase read/write design by default.
    • Runtime invariant documented in bible-local/architecture/runtime-flows.md.
  • Supersedes:
    • None.