I am using postgres 9.0 database , where In my C program I connect the database only once
and using fork I generate processes , where all my child program shares the connection
Most of the time it works correctly ,
In some cases child A gets the query error of child B , and It also gets the query time out issues and all
My question is , Is there any wrong to share the connections ?
per second it may create 1 to 5 processes at the max
Note:
I never closes the connection at all
It’s not a good idea for threads to share a single database connection because you’ll run into the exact issue that you described in your question: one thread can get the output of another thread’s request. Instead, you’ll want each thread to connect separately. If you have a lot of threads, you might want to consider making a connection pool.