Skip to content

DEADLINE_EXCEEDED #140

@beliven-daniele-sarnari

Description

@beliven-daniele-sarnari

Hello,

we are using this library with a cloud run laravel instance.
For some reasons CloudTasks is reading a deadline of 60s, even if the Job timeout is set to 300s.

Task content:

{
  "uuid": "a06da189-83dd-4366-b3ab-cedc1fd7ba22",
  "displayName": "App\\Jobs\\TestJob",
  "job": "Illuminate\\Queue\\CallQueuedHandler@call",
  "maxTries": null,
  "maxExceptions": null,
  "failOnTimeout": false,
  "backoff": null,
  "timeout": 300,
  "retryUntil": null,
  "data": {
    "commandName": "App\\Jobs\\TestJob",
    "command": "O:16:\"App\\Jobs\\TestJob\":1:{s:4:\"\u0000*\u0000n\";i:20;}"
  },
  "telescope_uuid": "9b75e5de-bd34-4869-89a5-da98d7df4fa1",
  "internal": {
    "attempts": 0
  }
}

CloudTask logs error:

{
  "insertId": "1thj77cc3yy",
  "jsonPayload": {
    "@type": "type.googleapis.com/google.cloud.tasks.logging.v1.TaskActivityLog",
    "attemptResponseLog": {
      "attemptDuration": "60.027352s",
      "dispatchCount": "3",
      "maxAttempts": 0,
      "responseCount": "0",
      "retryTime": "2024-03-01T15:58:03.376746Z",
      "scheduleTime": "2024-03-01T15:57:01.149385Z",
      "status": "DEADLINE_EXCEEDED",
      "targetAddress": "POST https://crun-europe-west1-6nag4uco6a-ew.a.run.app/handle-task",
      "targetType": "HTTP"
    },
    "task": "projects/pj-cloud-run-debug/locations/europe-west1/queues/ctqu-europe-west1/tasks/App-Jobs-TestJob-6232a47d-a86d-4a5e-a144-74acd5803a33-1709308500725"
  },
  "logName": "projects/pj-cloud-run-debug/logs/cloudtasks.googleapis.com%2Ftask_operations_log",
  "receiveTimestamp": "2024-03-01T15:58:03.457366806Z",
  "resource": {
    2
  },
  "severity": "ERROR",
  "timestamp": "2024-03-01T15:58:02.976792965Z",
}

TestJob:

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class TestJob implements ShouldQueue
{
    use Dispatchable;
    use InteractsWithQueue;
    use Queueable;
    use SerializesModels;

    public int $timeout = 300;

    protected $n;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($n)
    {
        $this->n = $n;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $result = $this->fibonacci($this->n);
        info("Fibonacci result for {$this->n} is {$result}");

        sleep(60);

        info("Job finished after waiting for 2 minutes.");
    }

    /**
     * Calcola il numero di Fibonacci.
     *
     * @param int $n
     * @return int
     */
    protected function fibonacci($n)
    {
        if ($n <= 1) {
            return $n;
        }

        return $this->fibonacci($n - 1) + $this->fibonacci($n - 2);
    }
}

queue.php

'cloudtasks' => [
            'driver' => 'cloudtasks',
            'project' => env('STACKKIT_CLOUD_TASKS_PROJECT', ''),
            'location' => env('STACKKIT_CLOUD_TASKS_LOCATION', ''),
            'handler' => env('STACKKIT_CLOUD_TASKS_HANDLER', ''),
            'queue' => env('STACKKIT_CLOUD_TASKS_QUEUE', 'default'),
            'service_account_email' => env('STACKKIT_CLOUD_TASKS_SERVICE_EMAIL', ''),
            'signed_audience' => env('STACKKIT_CLOUD_TASKS_SIGNED_AUDIENCE', true),
            // Optional: The deadline in seconds for requests sent to the worker. If the worker
            // does not respond by this deadline then the request is cancelled and the attempt
            // is marked as a DEADLINE_EXCEEDED failure.
            'dispatch_deadline' => null,
            'backoff' => 0,
        ],

Thanks for the support

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions