Oracle 마이그레이션 이후 배치 실행시 ORA-08177 에러가 간혹 발생하였다.
ORA-08177: can't serialize access for this transaction (이 트랜잭션에 대한 직렬화 액세스를 할 수 없습니다)
JobRepository 설정 중 transactionManager의 IsolationLevelForCreate 속성을 따로 지정하지 않을 경우 기본으로 ISOLATION_SERIALIZABLE로 설정되기 때문에 발생한다. 이 속성을 ISOLATION_DEFAULT로 변경하면 된다.
@Configuration
public class BatchConfig extends DefaultBatchConfigurer {
private final DataSource dataSource;
private final PlatformTransactionManager transactionManager;
public BatchConfig(DataSource dataSource, PlatformTransactionManager transactionManager) {
this.dataSource = dataSource;
this.transactionManager = transactionManager;
}
@Override
protected JobRepository createJobRepository() throws Exception {
JobRepositoryFactoryBean factoryBean = new JobRepositoryFactoryBean();
factoryBean.setDataSource(dataSource);
factoryBean.setTransactionManager(transactionManager);
factoryBean.setIsolationLevelForCreate("ISOLATION_DEFAULT");
JobRepository jobRepository = factoryBean.getObject();
return jobRepository;
}
}
반응형
'자바 > Spring' 카테고리의 다른 글
IntelliJ Cannot resolve symbol 에러 (0) | 2023.10.20 |
---|---|
@RequestMapping 경로 '/' 유무 (1) | 2023.10.20 |
JPA @Embedded, @Embeddable, @AttributeOveride, @AssociationOveride (0) | 2023.10.17 |
Spring과 Spring Boot의 차이 (3) | 2023.10.17 |