#21329·vitess

VTTablet: a transaction whose connection closes under it never releases its transaction-limiter slot

Author: arthurschreiberCreated Oct 1, 2026Updated Oct 1, 2026
LabelsType: BugComponent: VTTablet

Not looking for external contributions on this one. We're already working in this area and intend to fix it ourselves. Please don't open a PR against this issue — it's filed to track the problem and record the analysis, not as an invitation. Comments and additional repro cases are very welcome.

Overview of the Issue

When a transaction's connection is closed while the transaction is still open, VTTablet never concludes the transaction. With --enable-transaction-limit, the caller's transaction-limiter slot is never given back, so each such transaction permanently takes one of the caller's slots until the tablet restarts. Once enough have leaked, every new transaction from that user fails with per-user transaction pool connection limit exceeded. The transaction is also missing from the transaction log and the Transactions timings.

Commit, rollback and the transaction killer conclude a transaction through TxPool.txComplete, which releases the limiter slot and logs the transaction. A connection closed under its transaction takes a different route:

  1. The connection is closed while the transaction is open. The common case is a query timeout inside a transaction: the timeout kills the whole connection, not just the query. Losing the connection to an error, a failed streamed CALL, and the pool shutting down all end the same way.
  2. When the request unlocks the connection, StatefulConnection.unlock sees it closed and calls ReleaseString("unlocked closed connection"), which unregisters it without concluding the transaction.
  3. The rollback VTGate sends next gets ABORTED, because the connection is gone. TxPool.Rollback also returns early for a connection that is closed but still registered, and the pool's Close releases in-transaction connections directly.

None of these paths calls txComplete.

Reproduction Steps

Unit-level, against main: begin a transaction through TxPool.Begin with a caller ID, close its connection (or run a query that outlasts its deadline), and unlock it. The limiter records the Get from Begin but no Release, and GetAndLock on the transaction ID returns ABORTED.

End to end: run VTTablet with --enable-transaction-limit and a small per-user limit, and run transactions whose statements hit the query timeout. After as many timeouts as the limit allows, the user can no longer begin transactions on that tablet.

Binary Version

main (e66114ee01). The paths are older than v23.

Operating System and Environment details

Any.

Log Fragments

per-user transaction pool connection limit exceeded