We encountered this error while running multithreaded performance tests on our application, which uses Javers for versioning of database changes. See below for full stack trace.
I think this looks like an error inside or while accessing the polyjdbc class Sequence without proper synchronisation for thread safety, so this may be a bug inside polyjdbc. Therefore I've created an issue for polyjdbc, too: polyjdbc/polyjdbc#22
Do you think this assumption for the cause of the exception is correct?
Suggestions for fixing this in Javers:
- either update polyjdbc when this issue is fixed in polyjdbc
- or implement a workaround to ensure thread safety in this case.
org.polyjdbc.core.exception.SequenceLimitReachedException: [SEQUENCE_LIMIT_REACHED] Sequence jv_commit_pk_seq has reached its limit of 8899. Before fetching value, check if recalculation is needed using recalculationNeeded() method. at org.polyjdbc.core.key.Sequence.nextValue(Sequence.java:50) ~[Sequence.class:?] at org.polyjdbc.core.key.SequenceAllocation.generateKey(SequenceAllocation.java:55) ~[SequenceAllocation.class:?] at org.polyjdbc.core.query.TransactionalQueryRunner.insert(TransactionalQueryRunner.java:108) ~[TransactionalQueryRunner.class:?] at org.javers.repository.sql.repositories.CommitMetadataRepository.insertCommit(CommitMetadataRepository.java:46) ~[CommitMetadataRepository.class:?] at org.javers.repository.sql.repositories.CommitMetadataRepository.save(CommitMetadataRepository.java:34) ~[CommitMetadataRepository.class:?] at org.javers.repository.sql.JaversSqlRepository.persist(JaversSqlRepository.java:63) ~[JaversSqlRepository.class:?] at org.javers.repository.api.JaversExtendedRepository.persist(JaversExtendedRepository.java:109) ~[JaversExtendedRepository.class:?] at org.javers.core.JaversCore.commit(JaversCore.java:80) ~[JaversCore.class:?] at org.javers.spring.jpa.JaversTransactionalDecorator.commit(JaversTransactionalDecorator.java:59) ~[JaversTransactionalDecorator.class:?] at org.javers.spring.jpa.JaversTransactionalDecorator$$FastClassBySpringCGLIB$$acb40bd0.invoke(<generated>) ~[JaversTransactionalDecorator.class:?] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[MethodProxy.class:4.2.4.RELEASE] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) ~[CglibAopProxy$CglibMethodInvocation.class:4.2.4.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[ReflectiveMethodInvocation.class:4.2.4.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[TransactionInterceptor$1.class:4.2.4.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) ~[TransactionAspectSupport.class:4.2.4.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[TransactionInterceptor.class:4.2.4.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[ReflectiveMethodInvocation.class:4.2.4.RELEASE] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[CglibAopProxy$DynamicAdvisedInterceptor.class:4.2.4.RELEASE] at org.javers.spring.jpa.JaversTransactionalDecorator$$EnhancerBySpringCGLIB$$aa8dbc27.commit(<generated>) ~[JaversTransactionalDecorator.class:?] at org.javers.spring.auditable.aspect.springdata.OnSaveAuditChangeHandler.handle(OnSaveAuditChangeHandler.java:18) ~[OnSaveAuditChangeHandler.class:?] at org.javers.spring.auditable.aspect.springdata.JaversSpringDataAuditableRepositoryAspect.applyVersionChange(JaversSpringDataAuditableRepositoryAspect.java:82) ~[JaversSpringDataAuditableRepositoryAspect.class:?] at org.javers.spring.auditable.aspect.springdata.JaversSpringDataAuditableRepositoryAspect.applyVersionChanges(JaversSpringDataAuditableRepositoryAspect.java:77) ~[JaversSpringDataAuditableRepositoryAspect.class:?] at org.javers.spring.auditable.aspect.springdata.JaversSpringDataAuditableRepositoryAspect.onVersionEvent(JaversSpringDataAuditableRepositoryAspect.java:59) ~[JaversSpringDataAuditableRepositoryAspect.class:?] at org.javers.spring.auditable.aspect.springdata.JaversSpringDataAuditableRepositoryAspect.onSaveExecuted(JaversSpringDataAuditableRepositoryAspect.java:47) ~[JaversSpringDataAuditableRepositoryAspect.class:?] at sun.reflect.GeneratedMethodAccessor1765.invoke(Unknown Source) ~[?:?]
We encountered this error while running multithreaded performance tests on our application, which uses Javers for versioning of database changes. See below for full stack trace.
I think this looks like an error inside or while accessing the polyjdbc class Sequence without proper synchronisation for thread safety, so this may be a bug inside polyjdbc. Therefore I've created an issue for polyjdbc, too: polyjdbc/polyjdbc#22
Do you think this assumption for the cause of the exception is correct?
Suggestions for fixing this in Javers:
org.polyjdbc.core.exception.SequenceLimitReachedException: [SEQUENCE_LIMIT_REACHED] Sequence jv_commit_pk_seq has reached its limit of 8899. Before fetching value, check if recalculation is needed using recalculationNeeded() method. at org.polyjdbc.core.key.Sequence.nextValue(Sequence.java:50) ~[Sequence.class:?] at org.polyjdbc.core.key.SequenceAllocation.generateKey(SequenceAllocation.java:55) ~[SequenceAllocation.class:?] at org.polyjdbc.core.query.TransactionalQueryRunner.insert(TransactionalQueryRunner.java:108) ~[TransactionalQueryRunner.class:?] at org.javers.repository.sql.repositories.CommitMetadataRepository.insertCommit(CommitMetadataRepository.java:46) ~[CommitMetadataRepository.class:?] at org.javers.repository.sql.repositories.CommitMetadataRepository.save(CommitMetadataRepository.java:34) ~[CommitMetadataRepository.class:?] at org.javers.repository.sql.JaversSqlRepository.persist(JaversSqlRepository.java:63) ~[JaversSqlRepository.class:?] at org.javers.repository.api.JaversExtendedRepository.persist(JaversExtendedRepository.java:109) ~[JaversExtendedRepository.class:?] at org.javers.core.JaversCore.commit(JaversCore.java:80) ~[JaversCore.class:?] at org.javers.spring.jpa.JaversTransactionalDecorator.commit(JaversTransactionalDecorator.java:59) ~[JaversTransactionalDecorator.class:?] at org.javers.spring.jpa.JaversTransactionalDecorator$$FastClassBySpringCGLIB$$acb40bd0.invoke(<generated>) ~[JaversTransactionalDecorator.class:?] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[MethodProxy.class:4.2.4.RELEASE] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720) ~[CglibAopProxy$CglibMethodInvocation.class:4.2.4.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[ReflectiveMethodInvocation.class:4.2.4.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[TransactionInterceptor$1.class:4.2.4.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) ~[TransactionAspectSupport.class:4.2.4.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[TransactionInterceptor.class:4.2.4.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[ReflectiveMethodInvocation.class:4.2.4.RELEASE] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) ~[CglibAopProxy$DynamicAdvisedInterceptor.class:4.2.4.RELEASE] at org.javers.spring.jpa.JaversTransactionalDecorator$$EnhancerBySpringCGLIB$$aa8dbc27.commit(<generated>) ~[JaversTransactionalDecorator.class:?] at org.javers.spring.auditable.aspect.springdata.OnSaveAuditChangeHandler.handle(OnSaveAuditChangeHandler.java:18) ~[OnSaveAuditChangeHandler.class:?] at org.javers.spring.auditable.aspect.springdata.JaversSpringDataAuditableRepositoryAspect.applyVersionChange(JaversSpringDataAuditableRepositoryAspect.java:82) ~[JaversSpringDataAuditableRepositoryAspect.class:?] at org.javers.spring.auditable.aspect.springdata.JaversSpringDataAuditableRepositoryAspect.applyVersionChanges(JaversSpringDataAuditableRepositoryAspect.java:77) ~[JaversSpringDataAuditableRepositoryAspect.class:?] at org.javers.spring.auditable.aspect.springdata.JaversSpringDataAuditableRepositoryAspect.onVersionEvent(JaversSpringDataAuditableRepositoryAspect.java:59) ~[JaversSpringDataAuditableRepositoryAspect.class:?] at org.javers.spring.auditable.aspect.springdata.JaversSpringDataAuditableRepositoryAspect.onSaveExecuted(JaversSpringDataAuditableRepositoryAspect.java:47) ~[JaversSpringDataAuditableRepositoryAspect.class:?] at sun.reflect.GeneratedMethodAccessor1765.invoke(Unknown Source) ~[?:?]