davidradl commented on code in PR #27970:
URL: https://github.com/apache/flink/pull/27970#discussion_r3109122242


##########
flink-filesystems/flink-s3-fs-native/src/main/java/org/apache/flink/fs/s3native/NativeS3BulkCopyHelper.java:
##########
@@ -70,10 +74,37 @@ class NativeS3BulkCopyHelper {
 
     private final S3TransferManager transferManager;
     private final int maxConcurrentCopies;
+    private final int maxConnections;
 
-    public NativeS3BulkCopyHelper(S3TransferManager transferManager, int 
maxConcurrentCopies) {
+    /**
+     * Creates a new bulk copy helper.
+     *
+     * @param transferManager the S3 transfer manager for async downloads
+     * @param maxConcurrentCopies the requested maximum number of concurrent 
copy operations
+     * @param maxConnections the HTTP connection pool size; if {@code 
maxConcurrentCopies} exceeds
+     *     this value, it is clamped down to prevent connection pool exhaustion
+     */
+    NativeS3BulkCopyHelper(
+            S3TransferManager transferManager, int maxConcurrentCopies, int 
maxConnections) {
+        checkArgument(maxConcurrentCopies > 0, "maxConcurrentCopies must be 
positive");
+        checkArgument(maxConnections > 0, "maxConnections must be positive");
         this.transferManager = transferManager;
-        this.maxConcurrentCopies = maxConcurrentCopies;
+        this.maxConnections = maxConnections;
+        if (maxConcurrentCopies > maxConnections) {
+            LOG.warn(
+                    "s3.bulk-copy.max-concurrent ({}) exceeds 
s3.connection.max ({}). "
+                            + "Clamping concurrent copies to {} to prevent 
connection pool exhaustion.",

Review Comment:
   nits :
   - I suggest saying `limiting` rather than` clamping ` as it is clearer.
   - I suggest calling the maxConcurrentCopies requestedMaxConcurrentCopies and 
maybe you could change the getter to getMaxConcurrentCopies. I do not think the 
caller needs to be aware that this is effective. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to