Client deadlocks when connecting via ssl

From: Amjith Ramanujam <amjith(dot)r(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Client deadlocks when connecting via ssl
Date: 2014-10-08 20:47:47
Message-ID: CAHUL3dpWYFnUgdgo95OHYDQ4kugdnBKPTjq0mNbTuBhCMG4xvQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I'm accessing Postgresql from Python using Psycopg2. I'm making multiple
calls from threads and once every few times it causes the script to lock up
and become unresponsive. This only happens if I'm also making HTTPS calls
in addition to Postgres TCP calls with SSL.

I've captured stack traces from the locked process using gdb (see
attachment). They all seem to point to libpq

#0 0x00007fff95d6f746 in __psynch_mutexwait () from
/usr/lib/system/libsystem_kernel.dylib
#1 0x00007fff963d6779 in _pthread_mutex_lock () from
/usr/lib/system/libsystem_pthread.dylib
#2 0x000000010fad5edf in pq_lockingcallback () from
/usr/local/lib/libpq.5.dylib
#3 0x000000010f90903d in CRYPTO_add_lock () from
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
#4 0x000000010f9ba528 in X509_verify_cert () from
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
#5 0x000000010f8dc882 in ssl_verify_cert_chain () from
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib
#6 0x000000010f8bd611 in ssl3_get_server_certificate () from
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib
#7 0x000000010f8bc427 in ssl3_connect () from
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib
#8 0x000000010fad522d in pqsecure_open_client () from
/usr/local/lib/libpq.5.dylib

System Details:

OSX Maverics
psql (PostgreSQL) 9.3.4
psycopg2 version 2.5.4

I'm also attaching the script (pg_hammer.py) that I used to trigger this
issue. The script spins up 20 threads and makes Postgres calls. Once every
10 iterations it also makes a call to https://google.com. It creates a log
file 'db_stats1.log' which is written to every time a call to Postgres is
successful.

The dead lock doesn't happen every time, but if you relaunch the script a
few times you'll see the issue pop up right away where the log file stops
spewing lines.

You might have to install the requests library (using `pip install
requests`) in order to run the script.

Please let me know if you need more details.

Cheers!
Amjith

Attachment Content-Type Size
stack1.txt text/plain 92.9 KB
pg_hammer.py text/x-python-script 2.3 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2014-10-09 00:45:44 Re: [BUGS] BUG #11608: ODBC driver crashes after wrong password entered
Previous Message eric.hill 2014-10-08 17:54:46 BUG #11608: ODBC driver crashes after wrong password entered