github-actions[bot] commented on code in PR #70910:
URL: https://github.com/apache/doris/pull/70910#discussion_r4675079309


##########
be/src/service/http/action/stream_load.cpp:
##########
@@ -458,6 +461,51 @@ void 
StreamLoadAction::free_handler_ctx(std::shared_ptr<void> param) {
     streaming_load_current_processing->increment(-1);
 }
 
+#ifndef BE_TEST
+// An empty address leaves planning on the existing master RPC path.
+static Status get_group_commit_planning_follower(const ClusterInfo& cluster,
+                                                 const TStreamLoadPutRequest& 
request,
+                                                 TNetworkAddress* follower) {
+    if (cluster.master_fe_http_port == 0 || cluster.curr_auth_token.empty()) {
+        return Status::OK();
+    }
+    HttpClient client;
+    auto endpoint = get_host_port(cluster.master_fe_addr.hostname, 
cluster.master_fe_http_port);
+    // Never forward the internal auth header to a redirect target.
+    RETURN_IF_ERROR(client.init((config::enable_https ? "https://"; : 
"http://";) + endpoint +
+                                        "/api/_group_commit_plan_route",
+                                false, HttpClient::AuthTokenMode::CLUSTER, 
false));
+    // A slow or unreachable HTTP endpoint must leave time for the master RPC.
+    client.set_timeout_ms(std::min(config::thrift_rpc_timeout_ms, 10000));
+    std::string db;
+    std::string table;
+    url_encode(request.db, &db);
+    url_encode(request.tbl, &table);
+    std::string body;
+    auto st = client.execute_post_request(fmt::format("db={}&table={}", db, 
table), &body);
+    long code = client.get_http_status();
+    if (code == 403) {
+        return Status::NotAuthorized("Master rejected group commit routing 
token");

Review Comment:
   [P2] Fall back when the optional routing token is stale
   
   `TokenManager.start()` creates fresh, nonpersistent tokens after a master FE 
restart, while surviving BEs retain `curr_auth_token` until a successful 
heartbeat. If that first heartbeat is delayed or fails while FE HTTP/RPC 
services become available, a valid password-authenticated load sent to a 
surviving BE gets 403 here and aborts. This also happens with follower 
forwarding disabled, because `groupCommitPlanRoute` checks the token before 
that setting. Previously the same request could succeed through 
`streamLoadPut`, which independently checks user credentials and LOAD 
privilege. Preserve that authenticated master-RPC fallback (or refresh and 
retry the routing token) so heartbeat timing alone does not fail otherwise 
valid group-commit loads.



##########
be/src/service/http/action/stream_load.cpp:
##########
@@ -458,6 +461,51 @@ void 
StreamLoadAction::free_handler_ctx(std::shared_ptr<void> param) {
     streaming_load_current_processing->increment(-1);
 }
 
+#ifndef BE_TEST
+// An empty address leaves planning on the existing master RPC path.
+static Status get_group_commit_planning_follower(const ClusterInfo& cluster,
+                                                 const TStreamLoadPutRequest& 
request,
+                                                 TNetworkAddress* follower) {
+    if (cluster.master_fe_http_port == 0 || cluster.curr_auth_token.empty()) {
+        return Status::OK();
+    }
+    HttpClient client;
+    auto endpoint = get_host_port(cluster.master_fe_addr.hostname, 
cluster.master_fe_http_port);
+    // Never forward the internal auth header to a redirect target.
+    RETURN_IF_ERROR(client.init((config::enable_https ? "https://"; : 
"http://";) + endpoint +

Review Comment:
   [P2] Select the route protocol from the FE endpoint
   
   `HeartbeatMgr.setMaster()` advertises `HttpURLUtil.getHttpPort()`, which is 
the FE HTTPS port when its `enable_https` is true. The BE flag used here 
controls the BE's own listener and can differ. With HTTPS enabled only on the 
FE, this sends plaintext to its TLS port; the reverse combination sends TLS to 
a plaintext FE. Direct routing therefore fails; when the mismatch produces a 
transport error, every load falls back to planning through the master and loses 
the CPU reduction this PR provides. Determine the FE protocol independently of 
the BE listener setting (the existing `SmallFileMgr` FE-download path already 
handles this distinction), and cover differing FE/BE HTTPS settings.



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