by Kevin Wiliarty.
In some cases when I have encountered this error increasing the `max_allowed_packet` size in `my.cnf` has made the difference. There's information about this -- although in reference to a dmlwriteexception -- as well as a suggestion to check the file format for InnoDB tables at:
https://docs.moodle.org/27/en/error/moodle/dmlwriteexception