| From: | Bruce Momjian <bruce(at)momjian(dot)us> |
|---|---|
| To: | Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM> |
| Cc: | "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: libpq is not thread safe |
| Date: | 2009-04-15 23:43:56 |
| Message-ID: | 200904152343.n3FNhuB05819@momjian.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Zdenek Kotala wrote:
> When postgreSQL is compiled with --thread-safe that libpq should be
> thread safe. But it is not true when somebody call fork(). The problem
> is that fork() forks only active threads and some mutex can stay locked
> by another thread. We use ssl_config mutex which is global.
>
> We need implement atfork handlers to fix this. See
> http://www.opengroup.org/onlinepubs/009695399/functions/pthread_atfork.html
>
> We should add pthread_atfork into _ini libpq section.
>
> Another problem with fork is that new process inherit connections and so
> on. Which is not also good, but it is happened also on single threaded
> application and developer can fix it in own code. Maybe some notice in
> documentation should help what application should do after fork.
Yep, added to TODO list:
Make libpq thread-safe in programs that use fork()
This requires the use of pthread_atfork() to release global locks
held in libpq
* http://archives.postgresql.org/pgsql-hackers/2009-04/msg00747.php
--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2009-04-15 23:44:56 | Re: GIN versus zero-key queries |
| Previous Message | Tom Lane | 2009-04-15 23:39:51 | Re: [GENERAL] Performance of full outer join in 8.3 |