activiti DBIdGenerator rollback

cancel
Showing results for 
Search instead for 
Did you mean: 
shangqiwen
Member II

activiti DBIdGenerator rollback

activiti  uses DBIdGenerator default, when the id block used up, it will request for another block from db, and increase its

current id status, but I am wondering when will the operation of writing id back to db be performed, 

if in the same transaction with other operation like update history identity_link, history_task_instance, what will occur when exception arisen? the id in DbIdGenerator wont rollback, and the new id wont commit to db, so next time it request for new block will result in using the old ids?

what I am missing?

4 Replies
daisuke-yoshimo
Senior Member

Re: activiti DBIdGenerator rollback

According to Activiti user guide, DbIdGenerator seems to be assumed to have problems.
https://www.activiti.org/userguide/#advanced.uuid.generator

> In some (very) high concurrency load cases, the default id generator may cause exceptions due to not being able to fetch new id blocks quickly enough.
> In (very) limited use cases this can cause problems when there is a real high load.

And, you can use the alternative(the org.activiti.engine.impl.persistence.StrongUuidGenerator)

> which generates a unique UUID locally and uses that as identifier for all entities. Since the UUID is generated without the need for database access, it copes better with very high concurrency use cases.

Or, you can use your original id generator by implementing interface IdGenerator and setting processEngineConfiguration.

shangqiwen
Member II

Re: activiti DBIdGenerator rollback

not in (very) high concurrency load cases, I mean, not because of high concurrency.

just because the operation of flushing id to db and other operations mix in one transaction,

if some exceptions arisen for business logic error, this will result in id rollback, and the id in DbIdGenerator wont rollback.

Hope this will express myself clear

shangqiwen
Member II

Re: activiti DBIdGenerator rollback

Sorry for asking a nonexistent question.

DbIdGenerator will use a REQUIRES_NEW propagation commandConfig, the source code is in ProcessEngineConfigurationImpl.

So, why there is a "duplicate key error" happened to activiti, still don't know how this happenes!

gdharley
Intermediate

Re: activiti DBIdGenerator rollback

I would recommend you use the StringUUid generator.

Even in low volume use cases I have seen issues with the standard ID generator.

Greg