Does camunda engine has cache consistency problem in the clustered environments?

Hi ALL,
After reading the camunda source code, I found that the onEntityLoaded method of DbEntityManager caches all data read from the database to the local cache.

  public void onEntityLoaded(DbEntity entity) {
    // we get a callback when the persistence session loads an object from the database
    DbEntity cachedPersistentObject = dbEntityCache.get(entity.getClass(), entity.getId());
    if(cachedPersistentObject == null) {
      // only put into the cache if not already present
      dbEntityCache.putPersistent(entity);

      // invoke postLoad() lifecycle method
      if (entity instanceof DbEntityLifecycleAware) {
        DbEntityLifecycleAware lifecycleAware = (DbEntityLifecycleAware) entity;
        lifecycleAware.postLoad();
      }
    }

  }

Querying entities will query from the local cache first and then query the database.

  public <T extends DbEntity> T selectById(Class<T> entityClass, String id) {
    T persistentObject = dbEntityCache.get(entityClass, id);
    if (persistentObject!=null) {
      return persistentObject;
    }

    persistentObject = persistenceSession.selectById(entityClass, id);

    if (persistentObject==null) {
      return null;
    }
    // don't have to put object into the cache now. See onEntityLoaded() callback
    return persistentObject;
  }

What puzzles me is how camunda ensure the cache consistency in the clustered environments?

For example, a taskEntity is cached in two processes, then modify the taskEntity through one process. After this certainly the taskEntity cached in this processes and the database was modified.

But in another process, the taskEntity in the local cache is still the old version, querying this taskEntity will return the old version, because the query will first query the local cache, and then query the database.

Maybe i’m wrong, please let me know

Thanks