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


##########
be/src/runtime/query_options_validation.cpp:
##########
@@ -0,0 +1,151 @@
+// 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) {
+    RETURN_IF_ERROR(validate_nonnegative_query_options(options));
+    // An explicit 0 or -1 creates an immediate or negative execution RPC 
deadline.
+    // An absent field retains the existing compatibility default.
+    if (options.__isset.execution_timeout && options.execution_timeout <= 0) {

Review Comment:
   [P1] Validate the `query_timeout` fallback too. When `execution_timeout` is 
unset, `RuntimeState::execution_timeout()` and 
`QueryContext::execution_timeout()` use `query_timeout`, but this validator 
only rejects nonpositive explicit `execution_timeout`. An older FE or direct 
RPC can send `query_timeout=-1` with `execution_timeout` unset; the changed RPC 
paths then receive `timeout_ms_for_int32(-1) == -1000` (or a negative widened 
timeout). Reject explicit nonpositive `query_timeout` here as well, and cover 
the fallback case.



##########
be/src/load/routine_load/routine_load_task_executor.cpp:
##########
@@ -296,6 +296,11 @@ Status RoutineLoadTaskExecutor::submit_task(const 
TRoutineLoadTask& task) {
     ctx->auth.token = _exec_env->cluster_info()->curr_auth_token;
 
     if (task.__isset.max_interval_s) {
+        // Consumers track elapsed milliseconds. Reject intervals that cannot 
fit that clock.
+        if (task.max_interval_s < 0 || task.max_interval_s > INT64_MAX / 1000) 
{

Review Comment:
   [P1] Reject oversized routine-load intervals before persisting the job. 
`CreateRoutineLoadInfo.MAX_BATCH_INTERVAL_PRED` still accepts every positive 
`long`, and ALTER parses the value without an upper bound; Kafka/Kinesis then 
serialize it unchanged. With `max_batch_interval=9223372036854775807`, this new 
BE check rejects `max_interval_s > INT64_MAX / 1000`, and 
`RoutineLoadTaskScheduler` renews/requeues the task on that submit error, so 
the accepted job can never start. Apply the same upper bound to CREATE and 
ALTER (or normalize the value consistently) before this task is scheduled.



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