Commit 41536db
fix(transaction): tolerate desynced cleanup rollback on startTransaction
A pooled connection can report a transaction it no longer holds after a
reconnect: Swoole's PDOProxy keeps its own inTransaction counter and does
not reset it in reconnect(), so it still reports an open transaction while
the underlying connection has none. startTransaction()'s cleanup rollBack()
then throws "There is no active transaction", which was rewrapped as
"Failed to start transaction" and aborted an otherwise-valid start.
Because the pool reclaims (rather than destroys) the connection on error,
the desynced connection stays in rotation and every subsequent transaction
on it fails the same way.
Make the pre-begin cleanup best-effort: swallow a PDOException from the
rollback and continue to beginTransaction() on the (clean, reconnected)
connection. The utopia PDO wrapper is unaffected as it reads the real
connection state; this only hardens the path when wrapped by a proxy that
tracks transactions independently.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 7e84398 commit 41536db
2 files changed
Lines changed: 49 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
76 | 83 | | |
77 | 84 | | |
78 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
0 commit comments