Replies: 1 comment
-
Great stuff !!!!
I just noticed an issue I did not see, we won't store new DEPLOYMENT_ID until code is deployed AND new WORKER is started. The restart is mandatory to store new DEPLOYMENT_ID in the DB. So unless you deploy AND curl or wait for next cron, this is not as good as new DEPLOY = stop polling 😭. Still a big improvement to current situation but not total elimination of forward compatibility requirement unless you add manually in your deploy the curl to reboot a process.
If you have multiple workers and new deployment is detected then polling stop, no new tasks are being processed. The question is when new Worker are getting started, there will probably be a delay between deployment detected (via curl e.g.) and new process being started. Unless similar to current implementation of imminent death detection, worker process start a new one. I am not sure what is happening if it is cron pinging for new process, I guess it depends on impementation (current or new proposed one or no cron + safety cf https://github.com/orgs/pgflow-dev/discussions/170. Not trivial.
For portability reason, just using the string DEPLOYMENT_ID and comparing it to current process DEPLOYMENT_ID seems sufficient. My 2 cents. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The Problem
When deploying a new Edge Function version on Supabase:
Why This Matters
This deployment overlap creates several challenges:
Proposed Solution: Deployment-Aware Workers
In short: Workers check if a newer deployment exists and stop polling for new work, allowing immediate cutover to new code.
Workers can detect when a newer deployment exists and gracefully stop polling while completing current work.
Implementation Approach
Deployment ID tracking:
DENO_DEPLOYMENT_ID
environment variable (available in production)<identifier>_<deployment_number>
(e.g.,abc123xyz_1
,def456uvw_2
)pgflow.workers
table when registeringDeployment check during heartbeat:
_
, take last part)Benefits:
Example Implementation
Integration with pg_cron Approach
The pg_cron-based polling approach (discussion #170) makes deployment detection even simpler: the HTTP request body can include the current deployment ID, allowing workers to compare against their own ID without any SQL queries.
Implementation Details to Discuss
What to store in workers table: Should we store:
abc123xyz_1
) - preserves all information1
) - simpler comparisons, less storageEnvironment detection: Need to reliably distinguish local dev from production:
DENO_DEPLOYMENT_ID
is missing locally, but is this enough to detect local env?SUPABASE_URL
pattern,IS_LOCAL
, etc.)?DENO_DEPLOYMENT_ID
is missing AND other local indicators presentCheck frequency: When should workers check for new deployments?
Questions
Other ideas
Related Discussions
Beta Was this translation helpful? Give feedback.
All reactions