Jump to solution
Details

The Fix

Set gssencmode default to disable in binary package builds to prevent crashes on MacOS when using multiprocessing.

Based on closed psycopg/psycopg issue #1136 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Open PR/Commit
@@ -35,6 +35,13 @@ env: OPENSSL_VERSION: "3.5.0" + # A string to differentiate build cacke keys to allow building different + # flavours of libpq in different branches without mixups. Currently used to + # make sure that libpq packages built for Psycopg 3.2 and 3.3 don't mix (in
fix.md
Option A — Apply the official fix\nSet gssencmode default to disable in binary package builds to prevent crashes on MacOS when using multiprocessing.\nWhen NOT to use: This fix is not applicable if Kerberos authentication is required for your application.\n\n

Why This Fix Works in Production

  • Trigger: Psycopg under multiprocessing on MacOS crash when kerberos authentication enabled (which is by default).
  • Mechanism: Fork unsafe code in psycopg causes crashes under Python multiprocessing on MacOS with Kerberos authentication enabled
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Fork unsafe code in psycopg causes crashes under Python multiprocessing on MacOS with Kerberos authentication enabled
  • Production symptom (often without a traceback): Psycopg under multiprocessing on MacOS crash when kerberos authentication enabled (which is by default).

Proof / Evidence

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“I asked the question on the -hackers mailing list.”
@dvarrazzo · 2025-08-23 · source
“Looks like the same issue as this https://github.com/urllib3/urllib3/issues/1179”
@stuaxo · 2025-08-23 · source
“In progress, and susceptible to discussion: - #1137 - #1139”
@dvarrazzo · 2025-08-26 · source
“Observation: there is a libpq function we currently don't wrap, (it was introduced in PG16), PQconnectionUsedGSSAPI(), that returns true if the connection was established via…”
@dvarrazzo · 2025-08-25 · source

Failure Signature (Search String)

  • Psycopg under multiprocessing on MacOS crash when kerberos authentication enabled (which is by default).
  • On an M2 Mac, I was having an issue where using postgres (via django), would crash Celery (usually, though not every time).
Copy-friendly signature
signature.txt
Failure Signature ----------------- Psycopg under multiprocessing on MacOS crash when kerberos authentication enabled (which is by default). On an M2 Mac, I was having an issue where using postgres (via django), would crash Celery (usually, though not every time).

Error Message

Signature-only (no traceback captured)
error.txt
Error Message ------------- Psycopg under multiprocessing on MacOS crash when kerberos authentication enabled (which is by default). On an M2 Mac, I was having an issue where using postgres (via django), would crash Celery (usually, though not every time).

What Broke

Celery crashes intermittently when using psycopg with PostgreSQL on MacOS.

Why It Broke

Fork unsafe code in psycopg causes crashes under Python multiprocessing on MacOS with Kerberos authentication enabled

Fix Options (Details)

Option A — Apply the official fix

Set gssencmode default to disable in binary package builds to prevent crashes on MacOS when using multiprocessing.

When NOT to use: This fix is not applicable if Kerberos authentication is required for your application.

Fix reference: https://github.com/psycopg/psycopg/pull/1139

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • This fix is not applicable if Kerberos authentication is required for your application.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Capture the exact failing error string in logs and tests so you can reproduce via a minimal script.
  • Pin production dependencies and upgrade only with a reproducible test that hits the failing path.

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.