X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id F1EC830F7C3 for ; Tue, 24 Jun 2003 08:25:48 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 58952-06 for ; Tue, 24 Jun 2003 05:25:38 -0300 (ADT) Received: from cpc-gw2.cpc.net.au (unknown [210.9.248.93]) by svr1.postgresql.org (Postfix) with ESMTP id 55E8D30F8C4 for ; Tue, 24 Jun 2003 05:25:37 -0300 (ADT) Received: from utiba.com by Utiba Mail Gateway (2.2.2) with ESMTP id h5O8Pa827301 for ; Tue, 24 Jun 2003 18:25:36 +1000 Received: from pc37.cpc.net.au (pc37.cpc.net.au [192.168.0.37]) by Utiba Mail Thingy (0.0.2) with ESMTP id h5O8PZx28866 for ; Tue, 24 Jun 2003 18:25:36 +1000 From: Philip Yarra Organization: Utiba Subject: ECPG still having thread problems on Linux Date: Tue, 24 Jun 2003 18:25:32 +1000 User-Agent: KMail/1.4.3 To: pgsql-interfaces@postgresql.org MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="------------Boundary-00=_KQ8ZFDIW96RHEWU2CL8D" Message-Id: <200306241825.32527.philip@utiba.com> X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=USER_AGENT_KMAIL X-Spam-Level: X-Archive-Number: 200306/72 X-Sequence-Number: 4283 --------------Boundary-00=_KQ8ZFDIW96RHEWU2CL8D Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, it looks like Lee's ECPG (and libpq) thread-safety patches have been applied, and configure --with-threads is also added. I have been doing some testing. On FreeBSD 4.8, the attached sample app runs without a problem. However, I still encounter a threading problem on Linux (RedHat 7.3). I have done the following: 1) cvs update 2) ./configure --with-threads && make && su -c "make install" 3) compiled cn.pgc as follows: a) ecpg -t cn.pgc b) gcc -I/usr/local/pgsql/include -L/usr/local/pgsql/lib \ -lecpg -lpgtypes -pthread cn.c 4) ./a.out - one thread runs to completion (inserts 5 records), the other hangs (manages one insert, then blocks forever) Using gdb, I attached to the thread that has locked up, and the backtrace looks like this: (gdb) backtrace #0 0x420e0187 in poll () from /lib/i686/libc.so.6 #1 0x4007d8cc in pqSocketPoll () from /usr/local/pgsql/lib/libpq.so.3 #2 0x4007d7ed in pqSocketCheck () from /usr/local/pgsql/lib/libpq.so.3 #3 0x4007d71f in pqWaitTimed () from /usr/local/pgsql/lib/libpq.so.3 #4 0x4007d6f5 in pqWait () from /usr/local/pgsql/lib/libpq.so.3 #5 0x4007bb53 in PQgetResult () from /usr/local/pgsql/lib/libpq.so.3 #6 0x4007bcbb in PQexec () from /usr/local/pgsql/lib/libpq.so.3 #7 0x40026d81 in ECPGexecute () from /usr/local/pgsql/lib/libecpg.so.4 #8 0x4002724c in ECPGdo () from /usr/local/pgsql/lib/libecpg.so.4 #9 0x08048927 in ins2 () #10 0x40043faf in pthread_start_thread () from /lib/i686/libpthread.so.0 Can anyone shed some light on why the behaviour differs between these two= =20 platforms?=20 Also, perhaps someone other there with access to a different Linux setup=20 (maybe a more recent build than RedHat 7.3, or a different distro) could tr= y=20 this app themselves to help verify if this is something that's stuffed on= =20 that release. I think I can rule out this problem being a quirk of my=20 particular setup, as 3 different machines (all running RH7.3) give identica= l=20 results. Build env: Linux 2.4.18-3 gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-113) Regards, Philip Yarra. --------------Boundary-00=_KQ8ZFDIW96RHEWU2CL8D Content-Type: text/x-csrc; charset="us-ascii"; name="cn.pgc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="cn.pgc" /* on linux, you can compile with: ecpg cn.pgc&& gcc -I/usr/local/pgsql/include -L/usr/local/pgsql/lib -lpgtypes -lecpg -lpthread cn.c and you'll need this table: CREATE TABLE foo ( message character(40) ); */ #include int main(); void ins1(); void ins2(); int main() { pthread_t thread1, thread2; pthread_create(&thread1, NULL, (void *) ins1, NULL); pthread_create(&thread2, NULL, (void *) ins2, NULL); pthread_join(thread1, NULL); pthread_join(thread2, NULL); printf("Done!"); return 0; } void ins1() { int i; EXEC SQL BEGIN DECLARE SECTION; char* cs = "test@host"; char* bar = "one!"; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER sqlerror sqlprint; EXEC SQL CONNECT TO :cs AS test1; EXEC SQL SET AUTOCOMMIT TO ON; for (i = 0; i < 5; i++) { printf("thread1 inserting\n"); EXEC SQL INSERT INTO foo VALUES(:bar); printf("==>thread1 insert done\n"); } EXEC SQL DISCONNECT test1; printf("done!\n"); } void ins2() { int i; EXEC SQL BEGIN DECLARE SECTION; char* cs = "test@host"; char* bar = "two!"; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER sqlerror sqlprint; EXEC SQL CONNECT TO :cs AS test2; EXEC SQL SET AUTOCOMMIT TO ON; for (i = 0; i < 5; i++) { printf("thread2 inserting\n"); EXEC SQL INSERT INTO foo VALUES(:bar); printf("==>thread2 insert done\n"); } EXEC SQL DISCONNECT test2; printf("done!\n"); } --------------Boundary-00=_KQ8ZFDIW96RHEWU2CL8D--