Spring Batch ORA-08177: impossible de sérialiser l'accès pour cette transaction lors de l'exécution d'un travail unique, niveau d'isolement SERIALIZED
Je reçois cette exception avec un niveau d'isolation sur JobRepository dans Spring Batch:
org.springframework.dao.CannotSerializeTransactionException: PreparedStatementCallback; SQL [INSERT into DATAFEED_APP.BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; ORA-08177: can't serialize access for this transaction
; nested exception java.sql.SQLException: ORA-08177: impossible de sérialiser l'accès à cette opération
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:269)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:812)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:868)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:872)
at org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.createJobInstance(JdbcJobInstanceDao.java:105)
at org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:135)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:172)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy27.createJobExecution(Unknown Source)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:117)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy61.run(Unknown Source)
quand runing un seul emploi, rien d'autre en parallèle. Quand je change de niveau d'isolation pour JobRepository à ISOLATION_READ_COMMITTED l'exception est allé.
Quelle est la raison de cette exception?
source d'informationauteur padis
Vous devez vous connecter pour publier un commentaire.
De officiel doc - 4.3.1
J'ai eu le même problème, et effectivement l'isolement dans jobRepository niveau est la clé, voici un exemple de code qui fonctionne pour moi:
Lors de l'utilisation de sérialisé transactions, vous devez augmenter la initrans paramètre sur la table par le Oracle Docs. Pour gérer sérialisé transactions ce doit être de 3 ou plus.
Nous avons essayé de monter INI_TRANS à 100, et que nous étions encore en cours d'exécution dans les questions
J'ai trouvé cet article qui suggère d'ajouter ROWDEPENDENCIES à la création des tables.
http://www.devx.com/dbzone/Article/41591?pf=true
Pour moi avec INI_TRANS & maintenant ROWDEPENDENCIES les exceptions pour Sérialisé ont disparu.
Mise à jour: s'avère ne pas être une solution parfaite. Nous avons eu un cas de ce SÉRIALISÉ exception arriver au cours de la nuit. Maintenant c'est beaucoup mieux comme nous l'avions 100s de cycles avant défaillance unique, mais il semble que l'utilisation de ROWDEPENDENCIES n'est pas encore une solution complète.
J'ai été en mesure de résoudre cette erreur en ajoutant isolationLevelForCreate comme ci-dessous: