Camunda process instance cleanup sync?

We have a database where we store user data and other stuff and then start a process instance for a process the user has to go through. We then also store the process instance id in this database.

Now we started using the camunda cleanup mechanism that gets rid of old process instances. This works great, but the problem now is, that my other database should be cleaned up too.

How do I get the information which process instances camunda cleaned up? I saw there’s a metric but just about how many process instances got cleaned up. Also in the cleanup job there’s no info afaik.

Do I have to sync that manually by using the rest api? Or are there easier ways?

Any hints? Thanks!

Hello @Steph ,

even Camunda does not know which process instances are cleaned up.

BUT: You could hook into the cleanup mechanism.

The cleanup is done with a field called removal_time_ that holds the timestamp from which the cleanup may be performed.

So once a root process instance is completed, the last transaction adds this timestamp to all records related to the root process instance.

You could now query this information and add it to your records as well. In that way, you can build the same mechanism and keep the process instance history data and your history data something like in sync.

Does this help you?

Jonathan

1 Like

Hi @jonathan.lukas,

Thanks. It helps. That’s what I had in mind also. We already know when a process is finished (or started). So we could just re-build the “same” cleanup on our side. There will be a short timeframe, when the databases are out of sync, but I guess we can (have to) live with that.

1 Like

Hi @Steph ,

regarding this:

There will be a short timeframe, when the databases are out of sync, but I guess we can (have to) live with that.

On the Camunda side, this also the case, as the history is batching through the different entities, and as there are no foreign key constraints between the history tables, you also have inconsistencies here.

This is by design, so there is anyway no chance that you sync it…

I hope this increases the confidence in your solution :slight_smile:

Jonathan

1 Like