Fix #1705 : MySQL connection might be lost after long operations