RuntimeService getVariables() causing Optimistic lock

We are using flowable 6.5.0 and mysql. We are getting FlowableOptimisticLockingException on invoking runtimeService.getVariables(processInstanceId).
It is working on a second try most of the time. Can you please suggest a solution for this?

org.flowable.common.engine.api.FlowableOptimisticLockingException: ByteArrayEntity[id=b4d18eb3-0adb-11eb-a85a-a86bad24f119, name=var-dds, size=7816] was updated by another transaction concurrently
at org.flowable.common.engine.impl.db.DbSqlSession.flushUpdates(DbSqlSession.java:572)
at org.flowable.common.engine.impl.db.DbSqlSession.flush(DbSqlSession.java:359)
at org.flowable.common.engine.impl.interceptor.CommandContext.flushSessions(CommandContext.java:192)
at org.flowable.common.engine.impl.interceptor.CommandContext.close(CommandContext.java:61)
at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:81)
at org.flowable.common.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:51)
at org.flowable.common.engine.impl.interceptorzLogInterceptor.execute(LogInterceptor.java:35)
at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:51)
at org.flowable.engine.impl.RuntimeServiceImpl.getVariables(RuntimeServiceImpl.java:216)

It’s very difficult to give an explanation without knowing more about the involved process models/instances, kind of data and amount of variables and these things …

How are you calling this API? The exception seems to indicate a serializable (?) variable was updated when calling this method and another transaction has changed the variable too. Hence, one transaction loses to avoid data corruption.