{"record":{"id":"7c8bc6095307f3fc","repo":"goharbor/harbor","slug":"there-are-more-than-one-task-with-the-same-job-id","errorCode":null,"errorMessage":"there are more than one task with the same job ID","messagePattern":"there are more than one task with the same job ID","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/controller/jobmonitor/monitor.go","lineNumber":164,"sourceCode":"\t\t\tlog.Errorf(\"failed to stop running job %s: %v\", jobID, err)\n\t\t\treturn err\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (w *monitorController) stopJob(ctx context.Context, jobID string) error {\n\ttasks, err := w.taskManager.List(ctx, &q.Query{Keywords: q.KeyWords{\"job_id\": jobID}})\n\tif err != nil {\n\t\treturn err\n\t}\n\tif len(tasks) == 0 {\n\t\t// the job is not found\n\t\tlog.Infof(\"job %s not found, maybe the job is already complete\", jobID)\n\t\treturn nil\n\t}\n\tif len(tasks) != 1 {\n\t\treturn fmt.Errorf(\"there are more than one task with the same job ID\")\n\t}\n\t// use local transaction to avoid rollback batch success tasks to previous state when one fail\n\tif ctx == nil {\n\t\tlog.Debug(\"context is nil, skip stop operation\")\n\t\treturn nil\n\t}\n\treturn orm.WithTransaction(func(ctx context.Context) error {\n\t\treturn w.taskManager.Stop(ctx, tasks[0].ID)\n\t})(orm.SetTransactionOpNameToContext(ctx, \"tx-stop-job\"))\n}\n\nfunc (w *monitorController) allRunningJobs(ctx context.Context) ([]string, error) {\n\tjobIDs := make([]string, 0)\n\twks, err := w.ListWorkers(ctx, all)\n\tif err != nil {\n\t\tlog.Errorf(\"failed to list workers: %v\", err)\n\t\treturn nil, err\n\t}","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/controller/jobmonitor/monitor.go#L146-L182","documentation":"Data-consistency error from jobmonitor stopJob: the task-manager query for job_id returned more than one task. Job IDs are expected to map to exactly one task; multiple matches indicate duplicated task rows and make it unsafe to stop the job.","triggerScenarios":"Thrown at src/controller/jobmonitor/monitor.go:164 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the task table for rows sharing the job_id and remove/fix duplicates.","Investigate why task creation duplicated the job ID (retry logic, race).","Re-run the stop after cleaning the data."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","contentChangedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}