Skip to content

Commit

Permalink
fix: fsm events failed when register task (#2225)
Browse files Browse the repository at this point in the history
fix: fsm events failed when register task.

When there is a high concurrency of registration tasks,
it can cause error InTransitionError, because of looplab/fsm library
uses optimistic locking to implement state transitions,
refer to https://github.com/looplab/fsm/blob/main/fsm.go#L312.

Signed-off-by: Gaius <gaius.qi@gmail.com>
  • Loading branch information
gaius-qi committed Jun 28, 2023
1 parent 0a9cd25 commit 2765aa8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scheduler/service/service_v1.go
Expand Up @@ -662,7 +662,7 @@ func (v *V1) triggerTask(ctx context.Context, req *schedulerv1.PeerTaskRequest,

// If the task triggers the TaskEventDownload failed and it has no available peer,
// let the peer do the scheduling.
if !task.FSM.Is(resource.TaskStateRunning) {
if task.FSM.Can(resource.TaskEventDownload) {
if err := task.FSM.Event(ctx, resource.TaskEventDownload); err != nil {
peer.Log.Errorf("task fsm event failed: %s", err.Error())
return err
Expand Down

0 comments on commit 2765aa8

Please sign in to comment.