Skip to content

stack: pg_net worker segfaults on a burst of requests on the native runtime (macOS) and puts Postgres into crash recovery #7555

Open

Description

@palexcast

Affected area

Database

Supabase CLI version

3.1.0

Operating system

macOS 27.0.1 (Apple silicon)

Installation method

npm (@supabase/cli-darwin-arm64)

Command

export SUPABASE_EXPERIMENTAL_STACK=1 SUPABASE_API_PORT=30810 SUPABASE_DB_PORT=30811
DB=postgresql://postgres:postgres@127.0.0.1:30811/postgres

for start in 1 2 3 4 5 6 7 8; do
  supabase stack stop
  supabase start --runtime native --exclude studio,mail,analytics,pooler,functions,storage,realtime
  psql "$DB" -c "create extension if not exists pg_net"
  for burst in 1 2 3; do
    psql "$DB" -c "select count(net.http_get('http://127.0.0.1:30810/rest/v1/')) from generate_series(1, 20)"
    sleep 4
  done
  grep -h "terminated by signal" ~/.supabase/stacks/*/logs/database/*/*
done

Actual output

On some starts the pg_net background worker segfaults while the 20 responses come back, and Postgres goes through crash recovery:

LOG:  database system is ready to accept connections
LOG:  background worker "pg_net 0.20.4 worker" (PID 44536) was terminated by signal 11: Segmentation fault: 11
LOG:  terminating any other active server processes
LOG:  all server processes terminated; reinitializing
LOG:  database system was not properly shut down; automatic recovery in progress
LOG:  database system is ready to accept connections

Per start, on a fresh supabase init project:

start 1: pg_net worker crashes 0 of 3 bursts
start 2: pg_net worker crashes 0 of 3 bursts
start 3: pg_net worker crashes 0 of 3 bursts
start 4: pg_net worker crashes 0 of 3 bursts
start 5: pg_net worker crashes 0 of 3 bursts
start 6: pg_net worker crashes 0 of 3 bursts
start 7: pg_net worker crashes 1 of 3 bursts

What I have seen so far:

  • It depends on the start, not on the data or the request. Most starts never crash, however much I send. A start that does crash keeps crashing: on one stack 68 of 72 bursts of 20 crashed the worker (mostly segfaults, some bus errors), until I ran supabase stack stop and supabase start. After that the same stack was fine again.
  • It needs several responses at once. On that crashing stack, bursts of 1 and 5 requests were fine, 10 crashed some of the time, 20 almost every time.
  • The target does not matter (REST, an Edge Function, another stack's gateway). Requests that fail to connect do not crash it.
  • Every connection gets "the database system is in recovery mode" while Postgres recovers, and net._http_response is emptied, so the responses are lost.
  • Once, the supabase start right after a crash failed with FATAL: pre-existing shared memory block (key 848085920, ID 851972) is still in use.

I could not get a stack trace: lldb fails to attach to the worker, and macOS writes no crash report for it.

Expected behavior

The pg_net worker handles the burst and Postgres stays up, as it does on the Docker stack, where we run the same pg_net version all day and have not seen this.

Steps to reproduce

  1. mkdir repro && cd repro && supabase init
  2. Run the loop above. It restarts the stack because only some starts crash. In my runs that was 1 start out of 7 here, and the first restart of another fresh project.

Additional context

  • Postgres 17.11.0.018-r0 (aarch64-apple-darwin), pg_net 0.20.4, default pg_net.batch_size (200)
  • We first hit this on our own project on the native runtime, where pg_cron jobs and end-to-end tests send pg_net requests: 11 crashes in one session.

I investigated this with help from an AI coding assistant (Claude Code), which also drafted this text. The results above come from real runs.

Activity

  1. self-assigned this
    on Nov 10, 2026
  2. palexcast commented on Nov 25, 2026

    @palexcast
    Author

    @7ttp do you know the status on this :)?
    It one of a few things that block migrating to stacks for local development.
    The two others being (supabase/edge-runtime#719 and #7274) which i think are quite serious.. Right now I work with an adjusted docker file (hacky workaround) locally that fixes 719 and 7274 in non-stack mode.

    All these 3 issues are quite critical in local development.

    At the same time, just want to take the opportunity to say thanks for all the work you do, greatly appreciated. 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions