Replies: 2 comments
|
This is the relevant doc from Supabase. You could probably also find more info looking at Deno deploy architecture as Supabase edge is their own port of that. When you get notice back the function is deployed the Gateway has switched the pointer around the world for your new function code. No requests coming in will go to spin up old function code or to old functions still alive in their lifecycle. Any functions running though will finish the "task" they are on. This is based on observation and discussion over the years and can't point you to anything else official from Supabase. I am not an employee and Github discussions are not monitored regularly by staff, but they do catch some things. |
Architectural Overview: Edge Functions Version Routing and Worker LifecycleIn the Supabase Edge Runtime architecture (built on Deno Deploy / V8 isolate technology and an edge routing proxy layer), deployment version cutovers and isolate lifecycles operate under strict distributed systems semantics. Here is the exact breakdown addressing each of your technical questions: 1. Does an ACTIVE deployment guarantee all new requests route exclusively to the new version?Yes, subject to edge routing metadata propagation (1 to 3 seconds). When a deployment transitions to
2. Can older worker instances continue accepting new requests after a deployment?No. Older worker instances enter a graceful draining state and do not accept new requests.
3. What is the maximum propagation or draining period?The maximum lifetime of an older version after a new deployment is bounded by:
Therefore, under standard synchronous HTTP invocations, *all execution of the older version is guaranteed to terminate within {\text{deploy}} + 155\text{ seconds} across the entire global fleet. 4. Does behavior differ across regions or during infrastructure restarts?
5. How to authoritatively verify that older versions have ceased executingYou can verify worker version retirement using both the Supabase Logs Explorer and custom headers:
6. Recommended Cutover Strategy for Security-Sensitive Storage OperationsWhile the Edge Runtime guarantees that new requests switch over rapidly, in distributed systems you should never rely on deployment timing alone for concurrency invariants or mutual exclusion, because an in-flight request on Version N-1 and a new request on Version N can overlap in execution during the 2–3 second propagation window. For sensitive Supabase Storage operations, adopt one of the following architectural patterns: A. Database-Level Advisory Locks (Recommended)Before performing the Storage operation, have the function acquire a PostgreSQL transactional advisory lock: -- In a helper RPC function called by your Edge Function:
create or replace function acquire_storage_lock(resource_key text)
returns boolean
language plpgsql
as $$
begin
-- Blocks or serializes concurrent executions on the same resource
perform pg_advisory_xact_lock(hashtext(resource_key));
return true;
end;
$$;Even if Version N-1 and Version N execute simultaneously during the drain window, the lock serializes their mutations deterministically. B. Storage Metadata Optimistic ConcurrencySupabase Storage maintains object metadata in the C. Maintenance Window / Pre-Cutover GateIf you must guarantee zero concurrent execution during the cutover:
|
Uh oh!
There was an error while loading. Please reload this page.
Hello Supabase team and community,
I'm looking for clarification about Edge Function deployment version routing and worker lifecycle.
We have an Edge Function that performs security-sensitive operations involving Supabase Storage. We recently deployed an updated version containing additional concurrency protections.
The latest version is marked ACTIVE in the Supabase dashboard, but we need to understand what happens to older deployed versions and already-running worker instances.
My questions are:
Once a new Edge Function version becomes ACTIVE, is it guaranteed that all new incoming requests are routed exclusively to that version?
Can older worker instances continue accepting new requests after a successful deployment?
Is there a documented maximum propagation or draining period after which previous versions can no longer execute?
Does the behavior differ across regions or during infrastructure restarts?
Is there an official method to verify that all previous worker versions have been retired?
For security-sensitive functions performing privileged Storage operations, what deployment or cutover strategy does Supabase recommend to prevent outdated code from executing?
We understand that Edge Functions have documented worker lifetime limits, but we would like to distinguish worker lifetime limits from guarantees about deployment routing and version retirement.
We are not reporting an active outage. We are trying to establish a reliable deployment safety procedure before enabling background processing.
Any official documentation, technical explanation, or guidance from the Edge Runtime team would be greatly appreciated.
Thank you!
All reactions