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 4DE6030FBC2 for ; Wed, 25 Jun 2003 09:35:58 +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 09599-04 for ; Wed, 25 Jun 2003 06:35:47 -0300 (ADT) Received: from internet.csl.co.uk (internet.csl.co.uk [194.130.52.3]) by svr1.postgresql.org (Postfix) with ESMTP id 97C5530FBBD for ; Wed, 25 Jun 2003 06:35:46 -0300 (ADT) Received: from euphrates.csl.co.uk (host-194-67.csl.co.uk [194.130.52.67]) by internet.csl.co.uk (8.12.8/8.12.8) with ESMTP id h5P9ZliM020572; Wed, 25 Jun 2003 10:35:47 +0100 Received: from kelvin.csl.co.uk by euphrates.csl.co.uk (8.9.3/ConceptI 2.4) id KAA08202; Wed, 25 Jun 2003 10:35:45 +0100 (BST) Received: from kelvin.csl.co.uk (localhost.localdomain [127.0.0.1]) by kelvin.csl.co.uk (8.12.8/8.12.8) with ESMTP id h5P9Zh8C019876; Wed, 25 Jun 2003 10:35:43 +0100 Received: (from lkind@localhost) by kelvin.csl.co.uk (8.12.8/8.12.8/Submit) id h5P9ZfcF019872; Wed, 25 Jun 2003 10:35:41 +0100 From: Lee Kindness MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="L3S3O3Klza" Content-Transfer-Encoding: 7bit Message-ID: <16121.27884.841077.431930@kelvin.csl.co.uk> Date: Wed, 25 Jun 2003 10:35:40 +0100 To: Philip Yarra Subject: ECPG still having thread problems on Linux In-Reply-To: <200306241825.32527.philip@utiba.com> References: <200306241825.32527.philip@utiba.com> X-Mailer: VM 7.07 under 21.4 (patch 12) "Portable Code" XEmacs Lucid Cc: Lee Kindness , pgsql-interfaces@postgresql.org X-Archive-Number: 200306/74 X-Sequence-Number: 4285 --L3S3O3Klza Content-Type: text/plain; charset=us-ascii Content-Description: message body text Content-Transfer-Encoding: 7bit Philip, both your SELECTs are using the same database connection (and it's undefined which one it is) without any locking. You need to add "AT clauses" to specify an explicit connection. See attached diff. However, i've not tried it... I'll try and get some time! L. Philip Yarra writes: > 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) --L3S3O3Klza Content-Type: text/plain Content-Disposition: inline; filename="cn.pgc.diff" Content-Transfer-Encoding: 7bit *** cn.pgc 2003-06-25 10:29:55.000000000 +0100 --- cn.pgc.new 2003-06-25 10:29:45.000000000 +0100 *************** *** 36,46 **** 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; --- 36,46 ---- EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER sqlerror sqlprint; EXEC SQL CONNECT TO :cs AS test1; ! EXEC SQL AT test1 SET AUTOCOMMIT TO ON; for (i = 0; i < 5; i++) { printf("thread1 inserting\n"); ! EXEC SQL AT test1 INSERT INTO foo VALUES(:bar); printf("==>thread1 insert done\n"); } EXEC SQL DISCONNECT test1; *************** *** 57,67 **** 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; --- 57,67 ---- EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER sqlerror sqlprint; EXEC SQL CONNECT TO :cs AS test2; ! EXEC SQL AT test2 SET AUTOCOMMIT TO ON; for (i = 0; i < 5; i++) { printf("thread2 inserting\n"); ! EXEC SQL AT test2 INSERT INTO foo VALUES(:bar); printf("==>thread2 insert done\n"); } EXEC SQL DISCONNECT test2; --L3S3O3Klza--