stackkit/laravel-google-cloud-tasks-queue

Getting error in stackkit_cloud_tasks, but task is carried out correctly

larsnedb opened this issue · 2 comments

Hello,
I'm having some issues with your library for my PHP Laravel application. (PHP 8.2, Laravel 9.52)

We were running version 3.3, but experienced a great amount of errors in our logs because it attempted to delete already deleted tasks. We then had someone to provide a patch for this fix, which you incorporated in version 3.4.1. See this thread. But while waiting for this new official release, we have been running his fork of this project since February.

Last week I tried to change my dependency version to 3.5.0, but then I had issues with some tasks failing.
I have a queue in GCP called "mail".
It turned out that certain emails tasks queued by our application were not sent out at all, but went to status = queued and remained there forever in the stackkit_cloud_tasks table. So basically we were unable to send out Forgotten password and registration emails. But other tasks using the same queue were working without problems. It is not clear to me why some tasks were working perfectly and others not at all, especially since they are using the same queue.

As you can see from the following screenshot, it seems that the task is first created, then pushed to the queue. But the last entry in the logs, says that attemptResponseLog.status = NOT_FOUND.
Skjermbilde 2023-12-01 kl  13 39 41

Today, I attempted to jump straight to version 3.6.2. This time, the task is executed and emails are actually sent from my application, but this time the tasks status in my stackkit_cloud_tasks table jumps straight to error with exception "Requested entity was not found". Full entry from stackkit_cloud_tasks.metadata:

{
  "events": [
    {
      "queue": "mail",
      "status": "queued",
      "datetime": "2023-12-04 10:26:00"
    },
    {
      "status": "running",
      "datetime": "2023-12-04 10:26:00"
    },
    {
      "status": "error",
      "datetime": "2023-12-04 10:26:01"
    }
  ],
  "payload": "<hidden>",
  "exception": "Google\\ApiCore\\ApiException: {\n    \"message\": \"Requested entity was not found.\",\n    \"code\": 5,\n    \"status\": \"NOT_FOUND\",\n    \"details\": []\n}\n"
}

So even though it seems that my application now is able to send out emails, I still get these errors in my logs, which I suspect also might lead to some unwanted retries.

So in version 3.5.0 some of my tasks go directly to status = queued and stays there forever, but in version 3.6.2, the task has status = error, but the tasks are actually carried out.

I'm not sure if this is enough for you to go after, but it seems there are still some issues with task statuses and maybe some unneeded deletion?
I hope you are able to have a look at this, please ask me if there is any more data I can provide for you.

Still can't seem to crack this issue 🙃

  • Can you provide the full stack/exception trace if possible?
  • Where is the app running, Cloud Run/AppEngine or somewhere else?
  • Is there a pattern what is or isn't working? Certain mails only? Other jobs work fine?

I'm thinking of two ways to approach it:

  1. Add a fallback in case an already-deleted job is attempted to be deleted:

Screenshot 2023-12-23 at 22 01 46

  1. If the above doesn't help, release a version of the package with extensive debug logging that will hopefully uncover the issue