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


##########
be/src/runtime/runtime_state.h:
##########
@@ -58,8 +58,11 @@ class ObjStorageFileSystem;
 } // namespace io
 class RuntimeFilter;
 
+int32_t timeout_ms_for_int32(int64_t seconds);
+
 inline int32_t get_execution_rpc_timeout_ms(int32_t execution_timeout_sec) {
-    return std::min(config::execution_max_rpc_timeout_sec, 
execution_timeout_sec) * 1000;
+    return timeout_ms_for_int32(

Review Comment:
   [P1] Reject or normalize negative execution RPC caps. 
`execution_max_rpc_timeout_sec` is mutable but still has no validator; setting 
it to -1 makes this `std::min` return -1, so `timeout_ms_for_int32` yields 
-1000 and runtime-filter or exchange RPCs receive a negative deadline. Add the 
config bound or explicit sentinel handling before using it here.



##########
fe/fe-core/src/main/java/org/apache/doris/qe/FEOpExecutor.java:
##########
@@ -80,7 +80,9 @@ public FEOpExecutor(TNetworkAddress feAddress, 
OriginStatement originStmt, Conne
         this.feAddr = feAddress;
         this.originStmt = originStmt;
         this.ctx = ctx;
-        this.thriftTimeoutMs = (int) (ctx.getExecTimeoutS() * 1000 * 
RPC_TIMEOUT_COEFFICIENT);
+        // Widen seconds before multiplication. The final float-to-int 
conversion saturates
+        // at INT_MAX, so a large positive timeout cannot become a negative 
deadline.
+        this.thriftTimeoutMs = (int) (ctx.getExecTimeoutS() * 1000L * 
RPC_TIMEOUT_COEFFICIENT);

Review Comment:
   [P1] Bound every query-timeout millisecond conversion. This change widens 
FEOpExecutor, but MasterTxnExecutor, Coordinator.enqueue, and MasterTsoProvider 
still compute `getExecTimeoutS() * 1000` as int. A valid 
`query_timeout=2147484` therefore wraps negative in those paths, producing 
immediate or invalid deadlines for follower INSERT forwarding, workload-group 
queue admission, or follower TSO. Reuse the same saturating conversion there.



##########
fe/fe-common/src/main/java/org/apache/doris/common/Config.java:
##########
@@ -1223,10 +1266,12 @@ public class Config extends ConfigBase {
             description = "Minimum interval in seconds between snapshot offset 
persistence operations")
     public static int streaming_job_snapshot_offset_persist_interval_sec = 300;
 

Review Comment:
   [P1] Bound remote_fragment_exec_timeout_ms before adding the grace period. 
The new `minValue=0` still accepts `Long.MAX_VALUE`; `BackendServiceClient` 
then adds 5000 and wraps `execPlanTimeout` negative, so new remote-fragment RPC 
stubs expire immediately. Cap at `Long.MAX_VALUE-5000` or saturate the addition.



##########
fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java:
##########
@@ -2018,7 +2018,7 @@ private boolean loadTxnCommitImpl(TLoadTxnCommitRequest 
request) throws UserExce
                     + " fullDbName: " + fullDbName);
         }
         long timeoutMs = request.isSetThriftRpcTimeoutMs() ? 
request.getThriftRpcTimeoutMs() / 2
-                : Config.try_commit_lock_timeout_seconds * 1000;
+                : 
TimeUnit.SECONDS.toMillis(Config.try_commit_lock_timeout_seconds);

Review Comment:
   [P1] Reject negative commit-lock timeouts. `try_commit_lock_timeout_seconds` 
is mutable but unbounded; setting it to -1 makes this `TimeUnit` conversion 
negative, which is passed directly to `tryWriteLockTablesOrMetaException` and 
causes default load commits to fail immediately. Add a nonnegative config bound 
or explicit sentinel handling.



##########
be/src/runtime/query_options_validation.cpp:
##########
@@ -0,0 +1,145 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include "runtime/query_options_validation.h"
+
+#include <cmath>
+#include <cstdint>
+#include <limits>
+#include <string_view>
+
+#include "common/status.h"
+#include "gen_cpp/PaloInternalService_types.h"
+#include "gen_cpp/QueryCache_types.h"
+
+namespace doris {
+namespace {
+Status validate_nonnegative(bool is_set, int64_t value, std::string_view name) 
{
+    if (is_set && value < 0) {
+        return Status::InvalidArgument("{} must be >= 0, but was {}", name, 
value);
+    }
+    return Status::OK();
+}
+
+Status validate_nonnegative_spill_options(const TQueryOptions& options) {
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.spill_streaming_agg_mem_limit,
+                                         options.spill_streaming_agg_mem_limit,
+                                         "spill_streaming_agg_mem_limit"));
+    RETURN_IF_ERROR(validate_nonnegative(options.__isset.min_revocable_mem,
+                                         options.min_revocable_mem, 
"min_revocable_mem"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.spill_buffer_size_bytes,
+                                         options.spill_buffer_size_bytes,
+                                         "spill_buffer_size_bytes"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.spill_aggregation_partition_count,
+                                         
options.spill_aggregation_partition_count,
+                                         "spill_aggregation_partition_count"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.low_memory_mode_buffer_limit,
+                                         options.low_memory_mode_buffer_limit,
+                                         "low_memory_mode_buffer_limit"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.spill_hash_join_partition_count,
+                                         
options.spill_hash_join_partition_count,
+                                         "spill_hash_join_partition_count"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.spill_repartition_max_depth,
+                                         options.spill_repartition_max_depth,
+                                         "spill_repartition_max_depth"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.spill_join_build_sink_mem_limit_bytes,
+                                         
options.spill_join_build_sink_mem_limit_bytes,
+                                         
"spill_join_build_sink_mem_limit_bytes"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.spill_aggregation_sink_mem_limit_bytes,
+                                         
options.spill_aggregation_sink_mem_limit_bytes,
+                                         
"spill_aggregation_sink_mem_limit_bytes"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.spill_sort_sink_mem_limit_bytes,
+                                         
options.spill_sort_sink_mem_limit_bytes,
+                                         "spill_sort_sink_mem_limit_bytes"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.spill_analytic_sink_mem_limit_bytes,
+                                         
options.spill_analytic_sink_mem_limit_bytes,
+                                         
"spill_analytic_sink_mem_limit_bytes"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.spill_sort_merge_mem_limit_bytes,
+                                         
options.spill_sort_merge_mem_limit_bytes,
+                                         "spill_sort_merge_mem_limit_bytes"));
+    return Status::OK();
+}
+
+Status validate_nonnegative_query_options(const TQueryOptions& options) {
+    // Unset optional fields retain their existing defaults. Zero keeps its 
existing meaning.
+    RETURN_IF_ERROR(validate_nonnegative(options.__isset.data_queue_max_blocks,
+                                         options.data_queue_max_blocks, 
"data_queue_max_blocks"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.partition_topn_max_partitions,
+                                         options.partition_topn_max_partitions,
+                                         "partition_topn_max_partitions"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.partition_topn_pre_partition_rows,
+                                         
options.partition_topn_pre_partition_rows,
+                                         "partition_topn_pre_partition_rows"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.cte_max_recursion_depth,
+                                         options.cte_max_recursion_depth,
+                                         "cte_max_recursion_depth"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.runtime_filter_wait_time_ms,
+                                         options.runtime_filter_wait_time_ms,
+                                         "runtime_filter_wait_time_ms"));
+    RETURN_IF_ERROR(validate_nonnegative(options.__isset.scan_queue_mem_limit,
+                                         options.scan_queue_mem_limit, 
"scan_queue_mem_limit"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.inverted_index_max_expansions,
+                                         options.inverted_index_max_expansions,
+                                         "inverted_index_max_expansions"));
+    
RETURN_IF_ERROR(validate_nonnegative(options.__isset.parallel_scan_min_rows_per_scanner,
+                                         
options.parallel_scan_min_rows_per_scanner,
+                                         
"parallel_scan_min_rows_per_scanner"));
+    return validate_nonnegative_spill_options(options);
+}
+} // namespace
+
+Status validate_query_options(const TQueryOptions& options) {

Review Comment:
   [P1] Reject nonpositive execution_timeout before creating RPC state. This 
central validator checks several wire options but omits optional 
`execution_timeout`; an explicit 0 or -1 reaches `timeout_ms_for_int32()` and 
produces an immediate or negative deadline in exchange and runtime-filter RPCs. 
Validate it here; the FE query-timeout checker already rejects nonpositive 
values.



##########
fe/fe-common/src/main/java/org/apache/doris/common/Config.java:
##########
@@ -1192,19 +1232,22 @@ public class Config extends ConfigBase {
      * than BE config 'max_routine_load_thread_pool_size'(default 1024),
      * which is the routine load task thread pool max size on BE.
      */
-    @ConfField(mutable = true, masterOnly = true)
+    // Zero can stop scheduling; a negative task capacity has no meaning.
+    @ConfField(minValue = "0", mutable = true, masterOnly = true)
     public static int max_routine_load_task_num_per_be = 1024;
 
     /**

Review Comment:
   [P1] Do not accept zero clone deadlines. Setting either clone timeout bound 
to 0 can make `getApproximateTimeoutMs()` return `taskTimeoutMs=0` (for 
example, a sub-1MB tablet), while `TabletSchedCtx.isTimeout()` asserts that 
this value is nonzero and throws. Require a positive bound or define explicit 
zero semantics in the scheduler.



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