{"record":{"id":"ceef32d55d05e261","repo":"dgraph-io/dgraph","slug":"task-queue-hasn-t-been-initialized-yet","errorCode":null,"errorMessage":"task queue hasn't been initialized yet","messagePattern":"task queue hasn't been initialized yet","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"worker/queue.go","lineNumber":133,"sourceCode":"\n// tasks is a persistent task queue.\ntype tasks struct {\n\t// queue stores the full Protobuf request.\n\tqueue chan taskRequest\n\t// log stores the timestamp, TaskKind, and TaskStatus.\n\tlog   *z.Tree\n\tlogMu *sync.Mutex\n\n\trng *rand.Rand\n}\n\n// Enqueue adds a new task to the queue, waits for 3 seconds, and returns any errors that\n// may have happened in that span of time. The request must be of type:\n// - *pb.BackupRequest\n// - *pb.ExportRequest\nfunc (t *tasks) Enqueue(req interface{}) (uint64, error) {\n\tif t == nil {\n\t\treturn 0, fmt.Errorf(\"task queue hasn't been initialized yet\")\n\t}\n\n\tid, err := t.enqueue(req)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\t// Wait for upto 3 seconds to check for errors.\n\tfor range 3 {\n\t\ttime.Sleep(time.Second)\n\n\t\tt.logMu.Lock()\n\t\tmeta := TaskMeta(t.log.Get(id))\n\t\tt.logMu.Unlock()\n\n\t\t// Early return\n\t\tswitch meta.Status() {\n\t\tcase TaskStatusFailed:","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/worker/queue.go#L115-L151","documentation":"Enqueue checks for a nil receiver; if the task queue (t) is nil it means the task queue was never initialized (e.g. when no WAL store is configured, such as running without the necessary storage setup). It returns this error instead of panicking on the nil pointer.","triggerScenarios":"Calling Enqueue (with a *pb.BackupRequest or *pb.ExportRequest) on a tasks instance that is nil — i.e. the server-side queue was never constructed/assigned, commonly when the node lacks the store backing t.log.","commonSituations":"Calling backup/export against an Alpha that started without task-queue initialization (e.g. reduced setup where the queue isn't wired); a library/embedded use of worker where tasks were never created; race where queue init hasn't run yet at startup.","solutions":["Verify the Alpha is started in a mode that initializes the task queue (check startup logs for task/queue init)","Upgrade/fix deployment so the WAL store is configured — the queue depends on it","Do not call Enqueue on a zero-value worker.tasks; obtain the queue from the server's initialized field","Guard callers with a nil check and surface a clearer configuration error"],"exampleFix":"// before\nid, err := tasks.Enqueue(req)\n// after\nif tasks == nil {\n    return 0, fmt.Errorf(\"backup/export not supported: task queue not initialized on this Alpha\")\n}\nid, err := tasks.Enqueue(req)","handlingStrategy":"type-guard","validationCode":"// Nil-check before use (mirrors the library's own guard)\nif tasks == nil {\n    return 0, fmt.Errorf(\"task queue not initialized on this Alpha\")\n}","typeGuard":"func queueReady(t *worker.Tasks) bool { return t != nil }","tryCatchPattern":"id, err := tasks.Enqueue(req)\nif err != nil {\n    if strings.Contains(err.Error(), \"hasn't been initialized\") {\n        return fmt.Errorf(\"backup/export unsupported in this deployment mode\")\n    }\n    return err\n}","preventionTips":["Confirm the Alpha runs in a mode that initializes the task queue","Check startup logs for task-queue initialization before offering backup/export","In embedded use, always construct the tasks struct via its constructor, never a zero value"],"tags":["initialization","nil-check","configuration","dgraph"],"backgroundTag":"not-initialized","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}