Postgres 7.4Beta2 Thread-safe

From: Thierry Missimilly <THIERRY(dot)MISSIMILLY(at)BULL(dot)NET>
To: postgres general <pgsql-general(at)postgresql(dot)org>
Cc: Thierry Missimilly <Thierry(dot)Missimilly(at)BULL(dot)NET>
Subject: Postgres 7.4Beta2 Thread-safe
Date: 2003-09-10 08:14:32
Message-ID: 3F5EDD68.1AE72FFC@BULL.NET
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm testing Postgresql-7.4beta2 on a RedHat 7.3 mono Pentium IV CPU
machine. And i think i have a Thread-safe problem. PostgreSQL
developpers will find a test program to reproduce it on their lab.

I've built Postgresql with the option --enable-thread-safety --with-tcl.

And now run a pgbench like program call pgbch.pgc (attached with this
mail).

The main differences of pgbch.pgc are :
1) Pro*c code
2) Multi-threaded
3) Some specific code for Oracle
4) Some specific dynamic trace for debug

To compile :

ecpg -o pgbhc.c pgbch.pgc
cc -g -D_THREAD_SAFE -D_REENTRANT -I /usr/local/pgsql/include -L
/usr/local/pgsql/lib -lpthread -lecpg -o pgbch pgbch.c

To execute :

pgbch -c3 -t10 -s10 base_s10

(you can add -d10 to have debug traces)

Well, the problem is that sometime pgbch hang. Run it 3 or 4 times and
it will hang.
I don't know if it is really link to Postgres and ECPG but if you
modifiy pgbch.pgc in the way that the transaction is limited to "BEGIN;
END; ", it will never hang.

pgbch with 3 clients means 4 processes, but when then hang occurs,
generally, one client has finished its 10 transactions and there still
are 3 processes.

A look at gdb (gdb pgbch <pid>) gives (See the attach file pgbch.gdb) :
1) The main thread is in pthread_join() waitting for the 2 other child
threads.
2) One thread has finished, but is hanged in pqSocketPoll()
3) The last other thread is waitting to start running in
__pthread_manager()

Well, i'm not an expert in Linux multi-thread, but it seems the thread
(2) is waitting from a message from the postgresql backend which never
comes and therefore blocks the others threads.

I hope this will help to give back Postgres 7.4 more robust.

Regards,
Thierry Missimilly

Attachment Content-Type Size
pgbch.gdb text/plain 3.2 KB
pgbch.pgc text/plain 18.4 KB
THIERRY.MISSIMILLY.vcf text/x-vcard 327 bytes

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2003-09-10 08:20:51 Re: Temp tables and copy
Previous Message Bruno BAGUETTE 2003-09-10 08:05:48 RE : How to convert a UnixTimestamp to a PostgreSQL date without using ::abstime ?