dgraph-io/dgraph · error
task failed
Error message
task failed
What it means
After enqueuing, Enqueue polls the task log for up to ~3 seconds and returns immediately with 'task failed' if the task's metadata transitions to TaskStatusFailed. This is the early-failure signal from the task worker — the task started and failed quickly (within the 3s window).
Source
Thrown at worker/queue.go:152
}
id, err := t.enqueue(req)
if err != nil {
return 0, err
}
// Wait for upto 3 seconds to check for errors.
for range 3 {
time.Sleep(time.Second)
t.logMu.Lock()
meta := TaskMeta(t.log.Get(id))
t.logMu.Unlock()
// Early return
switch meta.Status() {
case TaskStatusFailed:
return 0, fmt.Errorf("task failed")
case TaskStatusSuccess:
return id, nil
}
}
return id, nil
}
// enqueue adds a new task to the queue. This must be of type:
// - *pb.BackupRequest
// - *pb.ExportRequest
func (t *tasks) enqueue(req interface{}) (uint64, error) {
var kind TaskKind
switch req.(type) {
case *pb.BackupRequest:
kind = TaskKindBackup
case *pb.ExportRequest:
kind = TaskKindExportView on GitHub (pinned to 759e242be6)
Solutions
- Read the Alpha logs around the task ID for the underlying task error (this error itself carries no detail)
- Fix the task destination/permissions (e.g. S3 credentials, bucket, path) and re-enqueue
- Validate the request (BackupRequest/ExportRequest fields, target format) before enqueueing
- Instead of relying on Enqueue's 3s window, poll TaskStatus with the returned task ID for the authoritative status
Example fix
// before
id, err := tasks.Enqueue(req)
if err != nil { return err } // "task failed" with no detail
// after
id, err := tasks.Enqueue(req)
if err != nil {
return fmt.Errorf("task %d failed, see alpha logs for cause: %w", id, err)
}
// then poll task status for detailed progress
meta, err := tasks.Get(id) Defensive patterns
Strategy: try-catch
Validate before calling
// Validate the destination before enqueueing
classic := func() error {
if bucket == "" || accessKey == "" { return fmt.Errorf("incomplete backup destination") }
return nil
}() Try / catch
id, err := tasks.Enqueue(req)
if err != nil && strings.Contains(err.Error(), "task failed") {
// fetch real cause from alpha logs / task status
meta, _ := tasks.Get(id)
return fmt.Errorf("task %d failed: status=%v", id, meta.Status())
} Prevention
- Pre-validate backup/export destinations (credentials, paths, permissions)
- Do not rely on Enqueue's 3s early-return for final status; poll TaskStatus
- Grep Alpha logs by task ID for the underlying failure
- Test backup configuration with a dry run before scheduling it
When it happens
Trigger: Enqueue a backup or export request whose execution fails almost immediately (e.g. handler returns an error right away) so the polling loop observes TaskStatusFailed and returns fmt.Errorf("task failed").
Common situations: Backups failing instantly due to bad S3/destination credentials; export failing on an invalid or inaccessible target path; permission errors on the storage backend; malformed request parameters rejected by the task handler at start.
Related errors
- too many pending tasks, please try again later
- task does not exist or has expired
- illegal rune found "%c", expecting {
- JSON map is followed by illegal rune "%c"
- Malformed JSON
AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01).
Data as JSON: /api/errors/411b9bae02708447.
Report an issue: GitHub.