@@ -164,14 +164,17 @@ func (s *TaskScheduler) Close() {
164
164
s .cancel ()
165
165
}
166
166
167
- func (s * TaskScheduler ) checkProcessed (taskId string ) bool {
167
+ func (s * TaskScheduler ) checkProcessed (t * Task ) bool {
168
168
if ! s .enableProcessedCheck {
169
169
return true
170
170
}
171
+ if t .TaskStatus == TASK_STATUS_RUNNING {
172
+ return true
173
+ }
171
174
s .lock .Lock ()
172
175
defer s .lock .Unlock ()
173
176
174
- if _ , ok := s .processedTask [taskId ]; ! ok {
177
+ if _ , ok := s .processedTask [t . TaskId ]; ! ok {
175
178
if s .count >= s .bufflen {
176
179
// 满了, 清除一个头部数据
177
180
delete (s .processedTask , s .taskProcessedTime [s .head ].taskId )
@@ -181,10 +184,10 @@ func (s *TaskScheduler) checkProcessed(taskId string) bool {
181
184
s .head = 0
182
185
}
183
186
}
184
- s .processedTask [taskId ] = true
187
+ s .processedTask [t . TaskId ] = true
185
188
s .taskProcessedTime [s .tail ] = processTime {
186
189
t : time .Now (),
187
- taskId : taskId ,
190
+ taskId : t . TaskId ,
188
191
}
189
192
s .tail ++
190
193
if s .tail >= s .bufflen {
@@ -345,7 +348,7 @@ func (s *TaskScheduler) updateTaskStatus() {
345
348
func (s * TaskScheduler ) updateCallbackTask () {
346
349
for t := range s .config .CallbackReceiver .GetCallbackChannel (s .ctx ) {
347
350
// 可能是轮询已经处理过,或者重复回调
348
- if ! s .checkProcessed (t . TaskId ) {
351
+ if ! s .checkProcessed (& t ) {
349
352
continue
350
353
}
351
354
s .wg .Add (1 )
@@ -404,7 +407,7 @@ func (s *TaskScheduler) updateOnce(ctx context.Context) {
404
407
defer s .wg .Done ()
405
408
if st .TaskStatus == TASK_STATUS_FAILED {
406
409
// 已经回调处理过
407
- if ! s .checkProcessed (task . TaskId ) {
410
+ if ! s .checkProcessed (& task ) {
408
411
return
409
412
}
410
413
// 失败可以重试
@@ -429,7 +432,7 @@ func (s *TaskScheduler) updateOnce(ctx context.Context) {
429
432
}
430
433
} else if st .TaskStatus == TASK_STATUS_SUCCESS {
431
434
// 已经回调处理过
432
- if ! s .checkProcessed (task . TaskId ) {
435
+ if ! s .checkProcessed (& task ) {
433
436
return
434
437
}
435
438
s .export (ctx , & task )
0 commit comments