diff --git a/realis.go b/realis.go index ce9b3fa..07385d5 100644 --- a/realis.go +++ b/realis.go @@ -672,7 +672,23 @@ func (r *realisClient) CreateJob(auroraJob Job) (*aurora.Response, error) { func() (*aurora.Response, error) { return r.client.CreateJob(context.TODO(), auroraJob.JobConfig()) }, - nil, + func() (*aurora.Response, bool) { + getTaskResp, err := r.client.GetTasksStatus( + context.TODO(), + &aurora.TaskQuery{JobKeys: []*aurora.JobKey{auroraJob.JobKey()}}, + ) + + if err != nil { + return nil, false + } + + tasks := response.ScheduleStatusResult(getTaskResp).GetTasks() + if len(tasks) != int(auroraJob.GetInstanceCount()) { + return nil, false + } + + return nil, true + }, ) if retryErr != nil { diff --git a/retry.go b/retry.go index f0257ba..4a2ffbc 100644 --- a/retry.go +++ b/retry.go @@ -197,9 +197,12 @@ func (r *realisClient) thriftCallWithRetries( // Allow caller to provide a function which checks if the original call was successful before // it timed out. if verifyOnTimeout != nil { - resp, ok := verifyOnTimeout() + verifyResp, ok := verifyOnTimeout() if ok { - return resp, nil + r.logger.debugPrint("verified that the call went through successfully") + // Response might be different than the original. + return verifyResp, nil + } } }