From: | François Battail <francois(dot)battail(at)sipibox(dot)fr> |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | PQfinish() in a C multi-threaded application |
Date: | 2014-11-28 16:32:16 |
Message-ID: | 5478A390.3030705@sipibox.fr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2014-11-28 16:40:55 | Re: Solaris fails test with float8. |
Previous Message | Tom Lane | 2014-11-28 15:35:21 | Re: Solaris fails test with float8. |