[PyGreSQL] [patch] relinquish GIL while connecting to database

Christoph Zwerschke cito at online.de
Mon Sep 22 10:22:12 EDT 2008


Peter Schuller schrieb:
> I discovered today that on Debian sarge (yes I know, massively old)
> this patch actually does cause problems when libpq is built with krb5
> support.
> 
> It uses krb5 in a non-threadsafe fashion (such as in fe-auth.c). In
> modern versions of libpq there is additional locking, and there are
> comments specifically mentioning that it is needed for krb5.
> 
> The end-result is sporadic segfaults.

But this happens only when you have rules with krb4/krb5 active in your 
pg_hba.conf, right?

> I have not investigated exactly as of which version of libpq this
> should be fixed, but the sarge version is 7.4.7.

As far as I see, the precautions you mentioned have first been included 
in PG 8.0. So the problems should only appear when you're using native 
Kerberos with PG < 8.0, which is a quite deprecated configuration.

Maybe we should wrap the Py_BEGIN_ALLOW_THREADS in something like
#if PG_VERSION < 8.0 && (defined(krb4) || defined(krb5))
Though this checks only the pq lib against which PyGreSQL is built, not 
the one that is actually running on the system. But at least if you then 
build PyGreSQL on your old Debian system, things should work.

-- Christoph


More information about the PyGreSQL mailing list