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%.
@@ -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
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
- 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
- GitHub issue: #1136
- Fix PR: https://github.com/psycopg/psycopg/pull/1139
- Reproduced locally: No (not executed)
- Last verified: 2026-02-09
- Confidence: 0.80
- Did this fix it?: Yes (upstream fix exists)
- Own content ratio: 0.70
Discussion
High-signal excerpts from the issue thread (symptoms, repros, edge-cases).
“I asked the question on the -hackers mailing list.”
“Looks like the same issue as this https://github.com/urllib3/urllib3/issues/1179”
“In progress, and susceptible to discussion: - #1137 - #1139”
“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…”
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
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 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.
Fix reference: https://github.com/psycopg/psycopg/pull/1139
Last verified: 2026-02-09. Validate in your environment.
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.