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