{"record":{"id":"40ac20e5b1512a84","repo":"dgraph-io/dgraph","slug":"operation-s-is-already-running","errorCode":null,"errorMessage":"operation %s is already running","messagePattern":"operation (.+?) is already running","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/draft.go","lineNumber":173,"sourceCode":"\t\t// only one backup operation should be active any given moment. Also, indexing at higher\n\t\t// timestamp can also run concurrently with backup.\n\t\tfor otherId, otherOp := range n.ops {\n\t\t\tif otherId == opBackup {\n\t\t\t\treturn nil, errors.Errorf(\"another backup operation is already running\")\n\t\t\t}\n\t\t\t// Remove from map and signal the closer to cancel the operation.\n\t\t\tdelete(n.ops, otherId)\n\t\t\totherOp.SignalAndWait()\n\t\t}\n\tcase opIndexing:\n\t\tfor otherId, otherOp := range n.ops {\n\t\t\tswitch otherId {\n\t\t\tcase opBackup:\n\t\t\t\tif otherOp.ts < ts {\n\t\t\t\t\t// If backup is running at higher timestamp, then indexing can't be executed.\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\treturn nil, errors.Errorf(\"operation %s is already running\", otherId)\n\t\t\tcase opRollup:\n\t\t\t\t// Remove from map and signal the closer to cancel the operation.\n\t\t\t\tdelete(n.ops, otherId)\n\t\t\t\totherOp.SignalAndWait()\n\t\t\tdefault:\n\t\t\t\treturn nil, errors.Errorf(\"operation %s is already running\", otherId)\n\t\t\t}\n\t\t}\n\tcase opSnapshot, opPredMove:\n\t\tfor otherId, otherOp := range n.ops {\n\t\t\tif otherId == opRollup {\n\t\t\t\t// Remove from map and signal the closer to cancel the operation.\n\t\t\t\tdelete(n.ops, otherId)\n\t\t\t\totherOp.SignalAndWait()\n\t\t\t} else {\n\t\t\t\treturn nil, errors.Errorf(\"operation %s is already running\", otherId)\n\t\t\t}\n\t\t}","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/draft.go#L155-L191","documentation":"Raised in startTaskAtTs (worker/draft.go:173) when a new indexing operation conflicts with an existing operation. Indexing cancels rollups, is blocked by a backup running at a lower (earlier) timestamp, and fails against any other running operation kind (restore, snapshot, predmove) via the default branch.","triggerScenarios":"Adding an index (AlterRequest with DropOp/IndexAttr) that triggers startTask(opIndexing) while n.ops holds a backup with otherOp.ts < ts, or any operation other than rollup/backup.","commonSituations":"Applying schema changes while a backup or restore runs; building several indexes concurrently on a busy cluster; snapshot streaming overlapping with index creation.","solutions":["Wait for the conflicting operation (backup/restore/snapshot) to complete, then re-issue the index build.","If a backup at an older timestamp blocks indexing, wait for it to finish — the message names the operation via %s.","Retry the schema alter after the background operation finishes; schema changes are idempotent.","Schedule schema/index changes outside backup windows."],"exampleFix":"// before: alter immediately during backup\nclient.Alter(schemaWithIndex)\n// after\nif err := client.Alter(schemaWithIndex); err != nil && strings.Contains(err.Error(), \"is already running\") {\n    waitForOpsToFinish()\n    client.Alter(schemaWithIndex)\n}","handlingStrategy":"retry","validationCode":"waitForNoRunningOps(cluster, [\"backup\",\"restore\",\"snapshot\"]) then applyIndexAlter()","typeGuard":null,"tryCatchPattern":"if err := client.Alter(schema); err != nil && strings.Contains(err.Error(), \"is already running\") {\n    <-opsFinished\n    return client.Alter(schema)\n}","preventionTips":["Never apply schema alters during backup/restore windows.","Queue schema migrations behind maintenance operations in CI/CD.","Monitor n.ops activity before deploying index changes."],"tags":["dgraph","indexing","operation-conflict"],"backgroundTag":"operation-already-running","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}