@@ -155,12 +155,6 @@ class ObEmbeddingTaskPhaseManager {
155155 }
156156};
157157
158- enum class ObEmbeddingTasSourceType
159- {
160- INDEX_PIPELINE = 0 ,
161- ASYNC_INDEX = 1 ,
162- };
163-
164158class ObEmbeddingTaskHandler ;
165159
166160// Constants for field lengths
@@ -175,14 +169,10 @@ class ObEmbeddingTask
175169 const ObString &provider,
176170 const ObString &user_key,
177171 const ObIArray<ObString> &input_chunks,
178- const ObCollationType col_type,
179172 int64_t dimension,
180173 int64_t http_timeout_us,
181174 int64_t http_max_retries,
182- int64_t source_task_id,
183- ObEmbeddingTasSourceType source_task_type,
184- storage::ObEmbeddingIOCallbackHandle *cb_handle = nullptr ,
185- bool always_retry = false );
175+ storage::ObEmbeddingIOCallbackHandle *cb_handle = nullptr );
186176 template <typename ThreadPoolType>
187177 int do_work (ThreadPoolType *thread_pool);
188178 int64_t get_task_id () const { return task_id_; }
@@ -191,56 +181,29 @@ class ObEmbeddingTask
191181
192182 TO_STRING_KV (K_(is_inited),
193183 K_ (task_id),
194- K_ (phase),
195184 K_ (model_url),
196185 K_ (model_name),
186+ K_ (user_key),
197187 K (input_chunks_.count()),
198188 K (output_vectors_.count()),
199189 K_ (dimension),
200190 K_ (batch_size),
201- K_ (current_batch_idx),
202- K_ (http_total_retry_count),
203- K_ (http_retry_count),
204- K_ (http_max_retry_count),
205- K_ (http_retry_start_time_us),
206- K_ (http_last_retry_time_us),
207191 K_ (processed_chunks),
208192 K_ (total_chunks),
209- K_ (process_callback_offset),
210- K_ (col_type),
211- K_ (current_input_token_limit),
212- K_ (need_cancel),
213- K_ (source_task_id),
214- K_ (source_task_type),
215- K_ (always_retry),
216- K_ (next_handle_task_time_us),
217- K_ (internal_error_code));
193+ K_ (process_callback_offset));
218194 bool is_completed ();
219195 void retain_if_managed ();
220196 void release_if_managed ();
221197 int get_async_result (ObArray<float *> &output_vectors);
222198 // 公共方法用于外部设置任务失败
223199 int mark_task_failed (int error_code);
224200 int maybe_callback ();
225- // Wait for task completion with periodic check interval
226- // @param check_interval_us: the interval to wait before returning, must be > 0
227- // @return:
228- // - OB_INVALID_ARGUMENT: if check_interval_us <= 0
229- // - OB_NOT_INIT: if task is not initialized
230- // - OB_SUCCESS: if task completed (callback_done_ is true)
231- // - OB_TIMEOUT: if task has exceeded wait_for_completion_timeout_us_ (real timeout)
232- // - OB_EAGAIN: if wait timed out but task not yet exceeded total timeout,
233- // caller should check cancel status and retry
234- // Usage: call in a loop, check for cancel between calls, handle OB_TIMEOUT as task failure
235- int wait_for_completion (int64_t check_interval_us);
201+ int wait_for_completion ();
236202 int wake_up ();
237203 void disable_callback ();
238204 void set_callback_done ();
239205 bool need_callback () { return cb_handle_ != nullptr ? true : false ; };
240- void set_need_cancel () { ATOMIC_STORE (&need_cancel_, true ); }
241- bool need_cancel () const { return ATOMIC_LOAD (&need_cancel_); }
242- common::ObCurTraceId::TraceId get_trace_id () const { return trace_id_; }
243- void set_always_retry (bool always_retry) { always_retry_ = always_retry; }
206+
244207public:
245208 static const ObString MODEL_URL_NAME;
246209 static const ObString MODEL_NAME_NAME;
@@ -252,35 +215,28 @@ class ObEmbeddingTask
252215 static const ObString USER_KEY_NAME;
253216 static const ObString INPUT_NAME;
254217 static const ObString DIMENSIONS_NAME;
255- static const ObString REQUEST_TOO_LARGE_ERROR_MSG;
256218
257219 static const int64_t HTTP_REQUEST_TIMEOUT; // 20 seconds
258220
259221 // Reschedule related constants
260222 static const int64_t MAX_RESCHEDULE_RETRY_CNT;
261223 static const int64_t RESCHEDULE_RETRY_INTERVAL_US;
262- static const int64_t MAX_NEXT_HANDLE_INTERVAL_US;
263224
264225 // HTTP retry related constants
265226 static const int64_t MAX_HTTP_RETRY_CNT;
266227 static const int64_t HTTP_RETRY_BASE_INTERVAL_US;
267228 static const int64_t HTTP_RETRY_MAX_INTERVAL_US;
268229 static const int64_t HTTP_RETRY_MULTIPLIER;
269- static const int64_t ALWAYS_RETRY_MIN_INTERVAL_US;
270- static const int64_t MIN_EMBEDDING_MODEL_RPM;
271- static const int64_t EMBEDDING_MODEL_WAIT_RATIO;
272230
273231 // Callback related constants
274232 static const int64_t CALLBACK_BATCH_SIZE;
275- static const int64_t MAX_INPUT_TOKEN; // Default max token count for each input: 512
276233
277234private:
278- void init_members (); // Common initialization for all constructors
279235 void reset ();
280236 bool is_finished () const ; // Internal use only - no lock needed
281- void set_stop (int ret_code );
237+ void set_stop ();
282238 int set_phase (ObEmbeddingTaskPhase new_phase);
283- int complete_task (int result_code, bool finished = true );
239+ int complete_task (ObEmbeddingTaskPhase new_phase, int result_code, bool finished = true );
284240 int start_async_work ();
285241 int check_async_progress ();
286242
@@ -300,24 +256,14 @@ class ObEmbeddingTask
300256 int parse_embedding_response (const char *response_data, size_t response_size);
301257
302258 // Helper methods for retry logic
303- bool should_retry_http_request (int64_t http_error_code, const ObString &http_error_msg ) const ;
259+ bool should_retry_http_request (int64_t http_error_code) const ;
304260 bool is_batch_size_related_error (int64_t http_error_code) const ;
305261 int64_t calculate_retry_interval () const ;
306262 int adjust_batch_size_for_retry ();
307- int adjust_input_token_limit_for_retry ();
308263 void reset_retry_state ();
309264 int map_http_error_to_internal_error (int64_t http_error_code) const ;
310265 void try_increase_batch_size ();
311266 int init_curl_handler (const ObString &model_url, const ObString &user_key, const int64_t http_timeout_us);
312- bool is_request_too_large (int64_t http_error_code, const ObString &content) const ;
313- int truncate_text_by_token_count (ObString &text, const ObCollationType cs_type, const int64_t max_token_count) const ;
314- bool can_retry_request () const { return http_retry_count_ < http_max_retry_count_; }
315- bool is_ready_to_handle () const ; // Check if current time exceeds next_handle_task_time_us_
316- int finish_task ();
317- int try_rescheule_task ();
318- int calc_max_wait_completion_time_us (int64_t http_timeout_us, int64_t http_max_retry_count,
319- int64_t batch_size, int64_t input_chunks_count,
320- int64_t &max_wait_completion_time_us) const ;
321267
322268 struct HttpResponseData {
323269 HttpResponseData (ObIAllocator &allocator) : data(nullptr ), size(0 ), allocator(allocator) {}
@@ -419,31 +365,20 @@ class ObEmbeddingTask
419365 int64_t wait_for_completion_timeout_us_; // For controlling the maximum timeout of waiting for completion
420366
421367 bool need_retry_flag_;
422- bool always_retry_; // If true, task can retry even after exceeding max retry count, but must wait at least 3 minutes
423- int64_t last_exceeded_retry_time_us_; // Time when retry count was exceeded
424368
425369 // Batch size adjustment for retry
426370 uint32_t original_batch_size_;
427371 bool batch_size_adjusted_;
428372 uint32_t current_batch_size_;
429373 uint32_t successful_requests_count_;
430374
431- // Input token limit adjustment for retry (when request too large)
432- int64_t current_input_token_limit_;
433-
434375 ObThreadCond task_cond_;
435376 bool callback_done_;
436377
437378 // TODO(fanfangyao.ffy): use taskhandle to manage task reference count
438379 // ref_cnt_ is only used to track the reference count of the post create embedding task
439380 int64_t ref_cnt_;
440- ObCollationType col_type_;
441- bool need_cancel_;
442- common::ObCurTraceId::TraceId trace_id_;
443- int64_t source_task_id_;
444- ObEmbeddingTasSourceType source_task_type_;
445- int64_t next_handle_task_time_us_;
446- ObEmbeddingTaskHandler *thread_pool_;
381+
447382 private:
448383 DISALLOW_COPY_AND_ASSIGN (ObEmbeddingTask);
449384};
0 commit comments