nsivarajan commented on code in PR #63918:
URL: https://github.com/apache/doris/pull/63918#discussion_r3332673176


##########
be/src/runtime/small_file_mgr.cpp:
##########
@@ -192,7 +189,32 @@ Status SmallFileMgr::_download_file(int64_t file_id, const 
std::string& md5,
         }
         return true;
     };
-    RETURN_IF_ERROR(client.execute(download_cb));
+
+    std::string url = "http://"; + host_port + query;
+    LOG(INFO) << "download file from: " << url;
+    HttpClient client;
+    RETURN_IF_ERROR(client.init(url));
+    Status execute_status = client.execute(download_cb);
+
+    if (!execute_status.ok()) {
+        rewind(fp.get());
+        if (ftruncate(fileno(fp.get()), 0) != 0) {
+            LOG(WARNING) << "fail to truncate temp file for https retry, 
errno=" << errno;
+        }
+        status = Status::OK();
+        digest = Md5Digest();
+
+        url = "https://"; + host_port + query;
+        LOG(INFO) << "HTTP failed, retrying with HTTPS: " << url;
+        HttpClient https_client;
+        RETURN_IF_ERROR(https_client.init(url));
+        // Skip TLS cert verification: internal cluster traffic only; file 
integrity
+        // is guaranteed independently by MD5 checksum verification below.

Review Comment:
   
   
   This PR is a Preparatory BE change: adds HTTPS fallback to _download_file(). 
When HTTP fails, it retries with HTTPS using use_untrusted_ssl() (safe for 
internal cluster traffic; MD5 checksum independently verifies file integrity).
   
   This PR causes no regression:
     - enable_https=false: HTTP succeeds on first try, no change.
     - enable_https=true, http_port=0 (without FE PR): both attempts fail as
       before — no change in outcome, ~1ms extra overhead on failure.
   
   **Activation**
   
     This fix takes effect automatically once the companion FE PR #60921  is 
merged. That PR changes HeartbeatMgr to send https_port to BEs when 
enable_https=true. From the next heartbeat
   cycle, master_fe_http_port on every BE becomes 8050, the HTTP attempt fails 
fast, and the HTTPS fallback succeeds — no BE restart or config change needed.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to