You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optimistic lock @Version used in IdGenerationImpl is redundant, and it can be removed to obtain better performance.
Detail Description
When a kind of id in memory is used up, a new batch of id would be retrieved from BLC_ID_GENERATION as show below. version field in BLC_ID_GENERATION is used as an optimistic lock to avoid concurrent modification to BLC_ID_GENERATION.
begin# read a new batch of id <= [BATCH_START, BATCH_START+BATCH_SIZE)select ID_TYPE, BATCH_SIZE, BATCH_START, ID_MIN, ID_MAX, version from BLC_ID_GENERATION where ID_TYPE='org.broadleafcommerce.profile.core.domain.Customer'# when update id information in database, use version field to ensure no other concurrent transaction has modified it# if there is no row updated, then it will throw OptimisticLockException update BLC_ID_GENERATION set BATCH_SIZE=50, BATCH_START=100, ID_MIN=null, ID_MAX=null, version=21where ID_TYPE='org.broadleafcommerce.profile.core.domain.Customer'and version=20commit
This optimistic lock is redundant, because in IdGererationServiceImpl#findNextId, which is the only function that may retrieve id from database, java synchronized has been used to prevent threads from access the same id type concurrently. So removing version field in BLC_ID_GENERATION to obtain slightly better performance is feasiable.
The text was updated successfully, but these errors were encountered:
Problem
Optimistic lock
@Version
used in IdGenerationImpl is redundant, and it can be removed to obtain better performance.Detail Description
When a kind of id in memory is used up, a new batch of id would be retrieved from BLC_ID_GENERATION as show below.
version
field in BLC_ID_GENERATION is used as an optimistic lock to avoid concurrent modification to BLC_ID_GENERATION.This optimistic lock is redundant, because in IdGererationServiceImpl#findNextId, which is the only function that may retrieve id from database, java synchronized has been used to prevent threads from access the same id type concurrently. So removing version field in BLC_ID_GENERATION to obtain slightly better performance is feasiable.
The text was updated successfully, but these errors were encountered: