After establishing a remote connection to a MySQL server (using the MySQL command-line front-end) I started executing a very long stored procedure (I estimate that it may take longer than 7 hours) but in the middle of it I received the error:
ERROR 2013 (HY000): Lost connection to MySQL server during query
So I guess that my query got timed-out. This procedure just stores some values in a
previously empty table.
After receiving this error and re-establishing the connection to the server I could
verify that the procedure somehow continued executing. And some time later I also verified
that the previously empty table now has some rows.
My question is, Can I trust that the procedure’s execution was correct even though the
connection was lost?
First, 7 hours seems too long. If the incompolete result bothers you, you could add some save point when N queries done, and combine the N queries into a single transaction. Then, Every time your procedure stops exceptionally, you could load the point you last saved.
I also suggest you could try to select the source data into your local pc, and make some script to get the result, then upload it to target table. This will reduce overhead on db server.