Mysql server has gone away

What is the main cause of the error ” MySQL server has gone away (BrokenPipeError(32, ‘Broken pipe’))\” message?
We are running Django server with rabbitmq, celery and mysql backend database. The server starts its connection without any issues but in our use case, objects getting saved to the database increase in size as new information for an entry comes in. This happens 3 to 5 times, with the object growing with each new addition, reaching a maximum size of 50-100mb. At the stage when the size is the largest, we see a failure to save the object (which is basically just JSON if that matters) with the above message. I believe this is happening either because the object is too large or more likely because, being large, it takes longer than the default timeout to get saved to the database. We have already tried changing ‘CONN_MAX_AGE’:290 and max_allwed_packet size= 1073741824 but doesn’t seem to help with the issue. Are there other parameters that could be at play here and are there ways that we can programmatically set them to values appropriate for our needs at build time? The application gets dockerized and deployed with Jenkins. So, a “permanent” solution that could be done automatically as part of this build process or set with settings.py would be ideal as opposed to mysql commands that would need to get set manually with each build.