Skip to content

Commit efbce13

Browse files
committed
Add comment to explain the reason to retry data integrity exceptions
Related to #5145 #4960
1 parent eac1ff5 commit efbce13

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/mongodb/MongoSequenceIncrementer.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2024-2025 the original author or authors.
2+
* Copyright 2024-present the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,6 +38,15 @@
3838
*/
3939
public class MongoSequenceIncrementer implements DataFieldMaxValueIncrementer {
4040

41+
/*
42+
* Retry template to handle errors when incrementing the sequence value
43+
* https://github.com/spring-projects/spring-batch/issues/4960
44+
*
45+
* Typically, only transient errors are retried, and even if
46+
* DataIntegrityViolationException extends NonTransientDataAccessException, the
47+
* MongoDB driver suggests to retry the operation on write conflict:
48+
* "Please retry your operation or multi-document transaction"
49+
*/
4150
private final RetryTemplate retryTemplate = new RetryTemplate(
4251
RetryPolicy.builder().includes(DataIntegrityViolationException.class).build());
4352

0 commit comments

Comments
 (0)