71 Replies
this cron scheduler
DOESNT WANNA WORK
I SCHEDULE IT RIGHT,
IT SAYS CRON IS CHEDULED AND ACTIVE
but my endpoint is never being hit!?

well it was hit once, when i tested manually calling that ngrok
to see if it would hit my endpoint and IT =DID
so why is that cron scheduler not working as it should?
Are you getting Postgres errors in the log?
If you look in this table do you see the cron running?

Most likely it is your POST call not working.

the latest ones are from ages ago
but this is because uhh i copied all the tables from my other project
so i copied all my schemas and data into my new DEV project replica
and all of a sudden the cron scheduler doesnt work
it says its running but no results are shown?
well old results are shown
from when i last ran it and when it worked with my original production project
So that cron code as you show used to run on another instance?
I always split out by cron code to a function and call that with the cron task code so I can debug with raise log in the function code.
yes correct, the exact same code i copied over
And there is nothing in the table I showed?
there is nothing new
its all old data
in the job run details
the job table does show correct, it even says its active
its supposed to run every 1 minute
but im not seeing any new rows
which means cron is not doing its job somehow
its not even calling anything, its not making a call, its not failing, its not making a new row how is that possible
not to mention but there is a bug when switchin projects, and when you have edge functions page uhh
selected
some bug where it says client code error
but that may be unrelated nayways,
but idk where to go from here, i think cron itself is not working as it should
I just ran
And it is running. It gets an error though because raise log won't work in SQL code (versus plpgsql).
Is the extension enabled?
I assume so if you see the cron task generated.
https://github.com/orgs/supabase/discussions/30168
Here is a guide on some things to check.
Restart your instance if those don't pan out.
Then contact support.
this shows cron jobs active


select * from cron.job_run_details order by start_time DESC limit 40;
see that, no new rows are being made
those are old data
Yes it looks like it is not running
yea, so cron is bugged?
No.
Your instance has an issue it seems.
Check out the link for debugging.
Or try a restart.

how i copied ur code
Yes and it runs on mine.
So something is wrong with your cron system. Hence the debug link.
oh right, i iwll take a look thanks
Basically the part of the guide that is relevant is to see if the schedule worker is running. And then restart the DB if not. You could just restart the db if you are not in production.

this did return a row lol
the job scheduler or cron is owned by the postgress user i checked
so permissions wise i dont think is problem
Try the restart anyway.
Then contact support I guess.
oh
hang on a second
i checked my other project and i see logs
but how is that possible if im running it from the other project
It is not possible.
oh thats what im seeing xD

those are all from today yea
Then you are setting and looking in two different instances.
hang on a second am i right?
are those from today
oh they are, but the time is off, that says 5pm
its 9pm right now, so those are old as well
So cron was working 4 hours ago on the system.
ah i might have ran it 4 hours ago on my the other project then
but the other one still aint working ever
Did you restart the DB?
ah lemme check how do i do that
i hope that fixes it
its restarting rn lmao
i really hope thats the fix
still aint working
nooooooooooooooooooooooooooooooooooooooo
can i uninstall cron somehwo or reinstall it
why is cron acting up
You can try that in the extensions tab of database.
If you are not getting any errors in the Postgres logs then you'll have to contact support. Not much users here can do unless we missed something obvious you are doing wrong.
theres no way i did something wrong, i copied ur code, i ran the cron scheduler exactly the same, so
its basically 1-1
you know something, my pg cron
was already installed in the other project?
is cron seperate for each project?
like i swear down, the pg cron was already installed in the other project that i setup hmmm, so
maybe osmehow, the two projects crons are already interlinked and its messing something ujp

not to mention i get this error switchin projects
when at the edge function page
although thats probably a seperate bug?
Is your extension on?
I assume it was as you did get the task in the queue.
I have no idea what that is and I toggle projects (4 or 5) all day long.
yea i checked extensions both projects have same extensions
you never seen that before?
it shows up 100% of the time for me
when i switch projects, and im at the edge functions page
No errors in dashboard on firefox/chrome windows 11.
Not done it from the edge functions page.
sorry i mean sql editor
i run the schedules from my sql editor
and when i swithc projects when at the sql editor it bugs out with sorry unexecpted error
kay i sent a suppor trequest for that bug issue, but i think im seeing two bugs then LMAO
the client side bug + cron bug
ah i got an email saying free plan may not be looked at
damn it well now what
should i uninstall the pg cron from my other project
extensions

LOOK AT THAT BS
new row was made
but only on my original project
not the replica i made
so my original project works, but the new one i made, it completely is messed up and not working why is that
You just mentioned replica...
by replica i mean i created a new project and ran the... commands to copy schemas and tables
manually made new project but rna some commands to copy the stuff over
OK not branching or read replicas.
nope
ah i used pg_dump
to dump the stuff
pg_dump and pg_restore
I have no idea at this point.
On your SQL editor thing... Are your instances in the same org?
On your SQL editor thing... Are your instances in the same org?
yes in same org

I don't do that with Free instances as they both then share the same free limits.
i didnt know that but one is dev version anyways
So I just tried 2 instances in the same org and I see how the SQL thing can get really messy. It keeps the SQL from one to the other.
I always have to go to an intermediate screen or use two tabs for my instances.
so knowing they are in the same org is the problem?
Not your cron issue directly.
but why is one project cron working and other not?
But I can see how easy it would be to run the SQL on the wrong instance.
I have no idea.
We have debugged what I know to debug.
damn it, well.................. s
i guess i will just run the cron job from my other project? i mean all its doing is calling an api
so it wouldnt even matter which one its from the cron running
You could pause the "bad" instance.
And start a new instance. Don't do anything but turn on Cron (if not on by default) and see if it works there.
Still does not solve what is wrong with your new instance though.
yea true hmmm what you mean by pausing the bad instance
how would i pause the cron
Pause the instance.
Just saying you can check the code on a new instance before doing anything else but the SQL for your cron task to point to a bad instance OR you are doing something or did something we did not find.
I don't recall ever encountering an instance cron not working after restart of the DB.
yea i must be a first for cron not to work
i guess thats not a good thing
so what does that mean...
hold on a second, should i try restarting my other project?
becuase maybe its using the other projects cron
1 org has 1 cron?
i dont understand, these projects are basically identical
and 1 has broken cron
i can barely even cacess
the sql editor
coz of that client editor bug
okay i guess i will just run my cron on my other project
that works
i hope they fix this issue i guess, but they probably wont look at it for like months
No each project/instance has it is own cron task. It is part of Postgres database and each project has its own database. All an org shares is billing metrics.
@garyaustin chat gpt solved the issue lol
it told me to run some pg cron uhhh reinstalling commands
and it said pg dump and restore is what broke the cron
Do you have those reinstalling commands?
-- Drop and reinstall the pg_cron extension
drop extension if exists pg_cron cascade;
create extension pg_cron;
⚠️ Warning: This will delete all current cron jobs on that project.