Billionmail/BillionMail · error

failed to update task pause status: %w

Error message

failed to update task pause status: %w

What it means

UpdateTaskPauseStatus updates is_paused and task_process on an email_tasks row. A failed UPDATE is wrapped as "failed to update task pause status: %w". This is a write failure at the DB level; the function logs success afterward only if the update succeeded.

Source

Thrown at core/internal/service/batch_mail/batch_mail.go:556

func UpdateTaskPauseStatus(ctx context.Context, taskId int, isPaused bool) error {
	pauseValue := 0
	processValue := 1

	if isPaused {
		pauseValue = 1
		processValue = 3
	}

	_, err := g.DB().Model("email_tasks").
		Where("id", taskId).
		Data(g.Map{
			"pause":        pauseValue,
			"task_process": processValue,
		}).
		Update()

	if err != nil {
		return fmt.Errorf("failed to update task pause status: %w", err)
	}

	g.Log().Info(ctx, "Updated task %d pause status: isPaused=%v, task_process=%d", taskId, isPaused, processValue)
	return nil
}

// UpdateTaskProcessStatus update task process status
func UpdateTaskProcessStatus(ctx context.Context, taskId int, status int) error {
	_, err := g.DB().Model("email_tasks").
		Where("id", taskId).
		Data(g.Map{"task_process": status}).
		Update()

	if err != nil {
		return fmt.Errorf("failed to update task process status: %w", err)
	}

	return nil

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Inspect the wrapped driver error to identify the DB cause
  2. Check for lock contention on the email_tasks row and long-running transactions
  3. Verify UPDATE permission on email_tasks and that writes go to the primary
  4. Retry the pause/resume operation once the DB is healthy
Defensive patterns

Strategy: retry

Validate before calling

if taskId <= 0 {
    return errors.New("invalid taskId")
}

Try / catch

if err := UpdateTaskPauseStatus(ctx, taskId, isPaused, process); err != nil {
    if isTransientDBError(err) {
        time.Sleep(time.Second)
        return UpdateTaskPauseStatus(ctx, taskId, isPaused, process)
    }
    return err
}

Prevention

When it happens

Trigger: PauseTask or ResumeTask calls this while the UPDATE fails: DB connection lost, table locked by long transactions, permission denied on UPDATE, or a trigger/constraint on email_tasks rejecting the values.

Common situations: Toggling pause/resume from the UI during a Postgres restart; concurrent bulk updates holding row locks; read-only replica routed for writes; schema change without the new columns present.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/f24b6b0900ff374c. Report an issue: GitHub.