cancel
Showing results for 
Search instead for 
Did you mean: 

activiti DBIdGenerator rollback

shangqiwen
Champ in-the-making
Champ in-the-making

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 4

daisuke-yoshimo
Star Collaborator
Star Collaborator

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
Champ in-the-making
Champ in-the-making

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
Champ in-the-making
Champ in-the-making

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
Elite Collaborator
Elite Collaborator

I would recommend you use the StringUUid generator.

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

Greg