Skip to content

Commit 246c1a6

Browse files
committed
fix: simplify removeObjects retry by retrying full set on transient failure
1 parent 039724d commit 246c1a6

1 file changed

Lines changed: 16 additions & 29 deletions

File tree

functional/TestMinioClient.java

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,6 @@
142142
justification = "Allow catching super class Exception since it's tests")
143143
public class TestMinioClient extends TestArgs {
144144
private static final int MAX_DELETE_ATTEMPTS = 5;
145-
// Matches the SDK's internal chunk size: MinioAsyncClient sets completed=true on the
146-
// first chunk that returns errors, dropping remaining chunks in the same call.
147-
private static final int DELETE_BATCH_SIZE = 1000;
148145
private static final Set<String> TRANSIENT_DELETE_CODES =
149146
Collections.unmodifiableSet(
150147
new HashSet<>(
@@ -1056,33 +1053,23 @@ public void removeObjects(String bucketName, List<ObjectWriteResponse> results)
10561053
}
10571054
}
10581055
anyTransient = false;
1059-
IOException nonTransientErr = null;
1060-
for (int i = 0; i < objects.size(); i += DELETE_BATCH_SIZE) {
1061-
List<DeleteRequest.Object> chunk =
1062-
objects.subList(i, Math.min(i + DELETE_BATCH_SIZE, objects.size()));
1063-
for (Result<DeleteResult.Error> r :
1064-
client.removeObjects(
1065-
RemoveObjectsArgs.builder().bucket(bucketName).objects(chunk).build())) {
1066-
DeleteResult.Error err = r.get();
1067-
String code = err.code();
1068-
if (!TRANSIENT_DELETE_CODES.contains(code)) {
1069-
if (nonTransientErr == null) {
1070-
nonTransientErr =
1071-
new IOException(
1072-
"non-transient delete error '"
1073-
+ code
1074-
+ "': "
1075-
+ err.message()
1076-
+ " on "
1077-
+ err.objectName()
1078-
+ " in bucket "
1079-
+ bucketName);
1080-
}
1081-
continue; // drain current chunk's response before throwing
1082-
}
1083-
anyTransient = true;
1056+
for (Result<DeleteResult.Error> r :
1057+
client.removeObjects(
1058+
RemoveObjectsArgs.builder().bucket(bucketName).objects(objects).build())) {
1059+
DeleteResult.Error err = r.get();
1060+
String code = err.code();
1061+
if (!TRANSIENT_DELETE_CODES.contains(code)) {
1062+
throw new IOException(
1063+
"non-transient delete error '"
1064+
+ code
1065+
+ "': "
1066+
+ err.message()
1067+
+ " on "
1068+
+ err.objectName()
1069+
+ " in bucket "
1070+
+ bucketName);
10841071
}
1085-
if (nonTransientErr != null) throw nonTransientErr;
1072+
anyTransient = true;
10861073
}
10871074
if (!anyTransient) break;
10881075
}

0 commit comments

Comments
 (0)