by Ken Task.
The errors
Error writing to database
Debug info: Got a packet bigger than 'max_allowed_packet' bytes
Are directly related to the setting of max_allowed_packet.
What is the value of max_allowed_packet?
Moodle docs state that should be at least 5000 - in your case, even higher. Do know this, that without that setting, there would be some strange errors reported. :|
4.9m characters of anything sounds like it's embedded - thus very large packets.
'SoS', Ken