@@ -29,6 +29,7 @@ const (
2929 pageSize = 500
3030 backfillLockKeyTemplate = "observability:tracehub:backfill:%d"
3131 backfillLockMaxHold = 24 * time .Hour
32+ backfillLockTTL = 3 * time .Minute
3233)
3334
3435// 定时任务+锁
@@ -43,7 +44,7 @@ func (h *TraceHubServiceImpl) BackFill(ctx context.Context, event *entity.BackFi
4344 )
4445 if h .locker != nil && event != nil {
4546 lockKey = fmt .Sprintf (backfillLockKeyTemplate , event .TaskID )
46- locked , lockCtx , cancel , lockErr := h .locker .LockWithRenew (ctx , lockKey , transformTaskStatusLockTTL , backfillLockMaxHold )
47+ locked , lockCtx , cancel , lockErr := h .locker .LockWithRenew (ctx , lockKey , backfillLockTTL , backfillLockMaxHold )
4748 if lockErr != nil {
4849 logs .CtxError (ctx , "backfill acquire lock failed" , "task_id" , event .TaskID , "err" , lockErr )
4950 return lockErr
@@ -311,7 +312,7 @@ func (h *TraceHubServiceImpl) fetchAndSendSpans(ctx context.Context, listParam *
311312 logs .CtxInfo (ctx , "completed listing spans, total_count=%d, task_id=%d" , totalCount , sub .t .GetID ())
312313 break
313314 }
314-
315+ listParam . PageToken = result . PageToken
315316 pageToken = result .PageToken
316317 }
317318
@@ -417,7 +418,7 @@ func (h *TraceHubServiceImpl) applySampling(spans []*loop_span.Span, sub *spanSu
417418// processSpansForBackfill handles spans for backfill
418419func (h * TraceHubServiceImpl ) processSpansForBackfill (ctx context.Context , spans []* loop_span.Span , sub * spanSubscriber ) error {
419420 // Batch processing spans for efficiency
420- const batchSize = 100
421+ const batchSize = 50
421422
422423 for i := 0 ; i < len (spans ); i += batchSize {
423424 end := i + batchSize
@@ -432,6 +433,8 @@ func (h *TraceHubServiceImpl) processSpansForBackfill(ctx context.Context, spans
432433 // Continue with the next batch without stopping due to a single failure
433434 continue
434435 }
436+ // ml_flow rate-limited: 50/5s
437+ time .Sleep (5 * time .Second )
435438 }
436439
437440 return nil
0 commit comments