Camunda execution variable having large size could not be stored in ACT_HI_VARINST table

In our application, we are setting an execution variable having large size around 21 MB in a Camunda process but we are getting the below error stating that the variable byte size is larger than the max_allowed_packet. This is leading to non completion of the process. We are using MySql as the process engine. Please let me know a solution forward.

Error updating database. Cause: java.sql.SQLNonTransientConnectionException: Got a packet bigger than ‘max_allowed_packet’ bytes

The error may involve org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity.insertHistoricVariableInstance-Inline

The error occurred while setting parameters

SQL: insert into ACT_HI_VARINST ( ID_, PROC_DEF_KEY_, PROC_DEF_ID_, PROC_INST_ID_, EXECUTION_ID_, ACT_INST_ID_, TENANT_ID_, CASE_DEF_KEY_, CASE_DEF_ID_, CASE_INST_ID_, CASE_EXECUTION_ID_, TASK_ID_, NAME_, REV_, VAR_TYPE_, BYTEARRAY_ID_, DOUBLE_, LONG_, TEXT_, TEXT2_ ) values ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )

Cause: java.sql.SQLNonTransientConnectionException: Got a packet bigger than ‘max_allowed_packet’ bytes’. Flush summary:

[
INSERT HistoricVariableInstanceEntity[24373063]
INSERT HistoricVariableInstanceEntity[24373066]
INSERT HistoricVariableInstanceEntity[24373067]
INSERT HistoricVariableInstanceEntity[24373068]
INSERT HistoricVariableInstanceEntity[24373071]
INSERT HistoricVariableInstanceEntity[24373073]
INSERT HistoricVariableInstanceEntity[24373075]
INSERT HistoricVariableInstanceEntity[24373079]
INSERT HistoricVariableInstanceEntity[24373081]
INSERT HistoricVariableInstanceEntity[24373083]
INSERT HistoricVariableInstanceEntity[24373085]
INSERT HistoricVariableInstanceEntity[24373086]
INSERT HistoricVariableInstanceEntity[24373088]
INSERT HistoricVariableInstanceEntity[24373091]
INSERT HistoricProcessInstanceEventEntity[24373061]
INSERT HistoricFormPropertyEventEntity[24373064]
INSERT HistoricActivityInstanceEventEntity[EndEvent_3:24373093]
INSERT HistoricActivityInstanceEventEntity[ServiceTask_1:24373078]
INSERT HistoricActivityInstanceEventEntity[ServiceTask_2:24373080]
INSERT HistoricActivityInstanceEventEntity[ServiceTask_3:24373065]
INSERT HistoricActivityInstanceEventEntity[ServiceTask_4:24373070]
INSERT HistoricActivityInstanceEventEntity[ServiceTask_5:24373087]
INSERT HistoricActivityInstanceEventEntity[ServiceTask_6:24373072]
INSERT HistoricActivityInstanceEventEntity[ServiceTask_8:24373089]
INSERT HistoricActivityInstanceEventEntity[StartEvent_1:24373062]
INSERT ByteArrayEntity[24373076]
INSERT ByteArrayEntity[24373084]
INSERT ByteArrayEntity[24373092]
]
at org.camunda.bpm.engine.impl.db.EnginePersistenceLogger.flushDbOperationException(EnginePersistenceLogger.java:115)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flushDbOperationManager(DbEntityManager.java:305)
at org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager.flush(DbEntityManager.java:281)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:203)
at org.camunda.bpm.engine.impl.interceptor.CommandContext.close(CommandContext.java:132)
at org.camunda.bpm.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:113)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:42)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.camunda.bpm.engine.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40)
at org.camunda.bpm.engine.impl.interceptor.ProcessApplicationContextInterceptor.execute(ProcessApplicationContextInterceptor.java:66)
at org.camunda.bpm.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.camunda.bpm.engine.impl.FormServiceImpl.submitStartForm(FormServiceImpl.java:74)

Hi

This stackoverflow thread may be of interest.

Have you considered an alternate storage architecture? For example, rather than store the large content as a process variable, store it as an object in say an AWS S3 bucket and then just store its URL as the process variable…

regards

Rob

Hi Rob,

Thanks for the prompt reply !
Need to check if there is a way we can avoid the history logging for this particular variable or process for quick fix.
Currently we are having history level as audit for the Camunda engine.

Regards,
Saumya