coollabsio / coolify

An open-source & self-hostable Heroku / Netlify / Vercel alternative.
https://coolify.io
Apache License 2.0
32.41k stars 1.7k forks source link

[Bug]: Incoming email notification "Coolify: [ACTION REQUIRED] Scheduled task (Cron scheduler) failed." #2630

Closed boryn closed 1 month ago

boryn commented 3 months ago

Description

Few times a day (~5) we receive email notification with subject: Coolify: [ACTION REQUIRED] Scheduled task (Cron scheduler) failed.

and with the content:

SQLSTATE[23505]: Unique violation: 7 ERROR:  duplicate key value violates unique constraint "scheduled_task_executions_uuid_unique"
DETAIL:  Key (uuid)=(zoo88ww) already exists. (Connection: pgsql, SQL: insert into "scheduled_task_executions" ("scheduled_task_id", "uuid", "updated_at", "created_at") values (4, zoo88ww, 2024-06-21 18:45:02, 2024-06-21 18:45:02) returning "id")

In the messages, the uuid changes like ggsw0s4, h04s4ss, etc.

Minimal Reproduction (if possible, example repository)

In the Scheduled Tasks there is only one defined job, it is Laravel's scheduler: php artisan schedule:run with frequency * * * * *

As the above error mentions "scheduled_task_executions" and duplicated uuid at this table, it must be something related to Coolify itself, this error does not come from the the commands fired by Laravel.

Exception or Error

No response

Version

v4.0.0-beta.297

boryn commented 3 months ago

Just got a new email at 08:35:

SQLSTATE[23505]: Unique violation: 7 ERROR:  duplicate key value violates unique constraint "scheduled_task_executions_uuid_unique"
DETAIL:  Key (uuid)=(vgsgwkc) already exists. (Connection: pgsql, SQL: insert into "scheduled_task_executions" ("scheduled_task_id", "uuid", "updated_at", "created_at") values (4, vgsgwkc, 2024-06-22 08:35:03, 2024-06-22 08:35:03) returning "id")

and what is interesting, at the Scheduled Task this run is indeed missing at the Recent executions list (though not sure yet if the task itself was run or not): image

This happens randomly at different times, no repeatable schedule for the notifications, screenshot with emails: image

Thijmen commented 3 months ago

I think the problem here is that Coolify current creates the uuid on the fly, whereas it should rely on the database to create that. It can be fixed but requires some effort as this happens on multiple places (E.g. deployments, applications, servers).

I am also curious what @andrasbacsai his standpoint on this is. If you ask me, the uuid should be database-generated, in order to prevent uuid collisions.

boryn commented 3 months ago

Additionally, I have noticed that the real used domain is not substituted in the email body and the link goes to "localhost"

image

andresledo commented 2 months ago

Any news on this matter? It is really annoying

Coolify: Scheduled task (Perfex) failed with output: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "scheduled_task_executions_uuid_unique" DETAIL: Key (uuid)=(n4wcs00) already exists. (Connection: pgsql, SQL: insert into "scheduled_task_executions" ("scheduled_task_id", "uuid", "updated_at", "created_at") values (2, n4wcs00, 2024-07-22 03:41:02, 2024-07-22 03:41:02) returning "id")

andrasbacsai commented 2 months ago

This will be fixed in the upcoming version. Coolify will use full length cuid2 (so more random) everywhere, not a 7 chars long cuid2.