Ref: CodecError { Packets out of sync } - possible failed reconnect after timeout · Issue #412 · blackbeam/rust-mysql-simple · GitHub
I have something that connects to a remote MySQL database and sometimes computes for over an hour with no transaction in progress but the MySQL connection pool still alive. Then the next MySQL request fails with
Failed: CodecError { Packets out of sync }
probably because the server closed the connection.
This is probably a bug in lost idle connection recovery; if there's a connection pool, it's the pool manager's job to handle this. So I sent in a bug report.
Known bug? Known workaround?
(What I really need to do is speed up that hour-long compute. I'm scaling something up and it turned out to have a part that's too slow. I can fix that, but would like to see this run to completion before diving into optimization.)
I think that happens when the statement / query results are not fully drained out. For example, if you run a query that returns 10 rows, only fetch 8 rows, then try to insert, an out-of-sync is triggered. But, it has been a great long while so I could easily be mistaken.
You can definitely cause it that way. But this code works fine until it has a really long compute period.
(Real fix: came up with an algorithm to reduce the compute from O(2^N) to O(N), which should reduce the hours-long delay to seconds.l)
So maybe there is a timeout on the database side, and that error isn't being handled?