I would recommend to focus on the "MySQL server has gone away" issue - that is the problem here. Although this particular one can have many possible reasons, if I remember correctly.
I believe the message about the locks ("A lock was created but not released") is just a consequence of this unexpected MySQL connection termination.