Skip to content

Commit

Permalink
refine error msg (#18916)
Browse files Browse the repository at this point in the history
refine error msg

Approved by: @daviszhen, @zhangxu19830126
  • Loading branch information
ck89119 committed Sep 23, 2024
1 parent db46836 commit 0d682dc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 1 addition & 4 deletions pkg/frontend/cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1477,10 +1477,7 @@ func runUpdateCdcTask(
updateCdcTaskFunc,
conds...,
)
if err != nil {
return err
}
return
return err
}

func updateCdcTask(
Expand Down
3 changes: 2 additions & 1 deletion pkg/taskservice/mysql_task_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,8 @@ func (m *mysqlTaskStorage) UpdateCdcTask(ctx context.Context, targetStatus task.
if (targetStatus == task.TaskStatus_ResumeRequested || targetStatus == task.TaskStatus_RestartRequested) && dTask.TaskStatus != task.TaskStatus_Paused ||
targetStatus == task.TaskStatus_PauseRequested && dTask.TaskStatus != task.TaskStatus_Running {
err = moerr.NewInternalErrorf(ctx,
"status can not be change, now it is %s",
"Task %s status can not be change, now it is %s",
dTask.Details.Details.(*task.Details_CreateCdc).CreateCdc.TaskName,
dTask.TaskStatus.String())
return 0, err
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/taskservice/mysql_task_storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,20 @@ func TestAddCdcTask(t *testing.T) {
assert.NoError(t, err)
assert.Greater(t, affected, 0)

mock.ExpectBegin()

dt.TaskStatus = task.TaskStatus_Paused
mock.ExpectQuery(selectDaemonTask + " order by task_id").WillReturnRows(
newDaemonTaskRows(t, dt),
)

_, err = storage.UpdateCdcTask(
context.Background(),
task.TaskStatus_PauseRequested,
callback2,
)
assert.Error(t, err)

mock.ExpectClose()
require.NoError(t, storage.Close())
}
Expand Down

0 comments on commit 0d682dc

Please sign in to comment.