pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedPQfinish() in a C multi-threaded application
2+ messages / 2 participants
[nested] [flat]
* PQfinish() in a C multi-threaded application
@ 2014-11-28 16:32 François Battail <francois.battail@sipibox.fr>
2014-11-28 18:59 ` Re: PQfinish() in a C multi-threaded application David G Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 2+ messages in thread
From: François Battail @ 2014-11-28 16:32 UTC (permalink / raw)
To: pgsql-bugs
Dear List,
I've a (large) multi-threaded application in C using PostgreSQL 9.3 on
Ubuntu 14.04 LTS x86_64 and it /seems/ that when a thread close a
connection using PQfinish() all pgsql connections *program wide* are
closed, here's an overview of this application:
main thread:
connect db
create tables
create worker threads (1 up to 20 workers)
wait for threads termination
analyze
index
close db
worker thread:
connect db
prepare statements
start transaction
mass insert (10.10^6 records)
end transaction
close db
All database connections are strictly isolated in local storage (auto)
variables.
When the main thread is trying to execute the SQL analyze statement,
after worker threads have completed, PQexec() fails and PQerrorMessage()
returns:
Creating tables...
Done.
Inserting...
Done.
Analyzing tables (be patient)...
Analyze failed, error: 1 (connection pointer is NULL)
If I don't call PQfinish() in the worker threads, the application just
runs completely fine and data are created as designed (checked with psql).
Am I missing something? I've seen so far nothing about such a behaviour
both in documentation and in Web searches (including this mailing list).
BTW forgive my bad English (I'm French ;-) )
Best regards
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: PQfinish() in a C multi-threaded application
2014-11-28 16:32 PQfinish() in a C multi-threaded application François Battail <francois.battail@sipibox.fr>
@ 2014-11-28 18:59 ` David G Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 2+ messages in thread
From: David G Johnston @ 2014-11-28 18:59 UTC (permalink / raw)
To: pgsql-bugs
François Battail wrote
> Dear List,
>
> I've a (large) multi-threaded application in C using PostgreSQL 9.3 on
> Ubuntu 14.04 LTS x86_64 and it /seems/ that when a thread close a
> connection using PQfinish() all pgsql connections *program wide* are
> closed, here's an overview of this application:
I would imagine that actually showing a small snippet of C code that
exhibits this behavior would make trouble-shooting a lot more viable.
Specifically the means of thread creation and connection creation/provision
in the main program, and the threads, needs to be shown in code and not some
imprecise description.
If you provide that those with actual knowledge of C and libpq may be able
to help.
David J.
--
View this message in context: http://postgresql.nabble.com/PQfinish-in-a-C-multi-threaded-application-tp5828600p5828622.html
Sent from the PostgreSQL - bugs mailing list archive at Nabble.com.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2014-11-28 18:59 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-11-28 16:32 PQfinish() in a C multi-threaded application François Battail <francois.battail@sipibox.fr>
2014-11-28 18:59 ` David G Johnston <david.g.johnston@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox