views:

35

answers:

1

Hello,

I'm trying to use the 8 threads from my new processor to handle transactions on the PostgreSQL database. It have to process geographic data in PostGIS, what I already do with just 1 processor core (one thread). I'm using Java (JDBC4) to create one Connection for each thread. Each connection receives the job to process groups of geometric entities, where one SELECT and one UPDATE statements are used for each entity. Each entity is processed by unique ID and no relation functions are used, so there is no dependencies between the transactions.

The application can be started to run with a variable number of threads. When I run it, all except one of the threads hang. Even if I try to run with just two threads, one hangs. With the "Server status" tool from pgAdmin3 I can see that all the hanging threads are "IDLE in transaction", some in "ExclusiveLock" mode, some in "RowExclusiveLock" mode and some in "AccessShareLock" mode.

I've adjusted my postgresql.conf as described in http://jayant7k.blogspot.com/2010/06/postgresql-tuning-quick-tips.html

I've tried to put the threads to sleep for a while right after the UPDATE statement with no success.

Why are the locks been created? Is there a way to avoid these locks, once that are no reasons to a query depend on other?

Thanks for any help

A: 

Did you set min-pool-size and max-pool-size for JDBC connection?

In your case, minimum should be 8.

nessence
Is "min-pool-size" and "max-pool-size" related to web development? It's not the case. It's a java application. I couldn't find a java class with similar methods.Also I've tried out the org.apache.commons.dbcp.BasicDataSource following this link http://www.java2s.com/Code/Java/Apache-Common/BasicDataSourceExample.htm with no success. The threads hanging on.
Alexandre
I'll try to split the process in 8 java application instances with the group reference given as command line argument and controll the job with shell script. I'll post the results.
Alexandre
It works when I divide the processing in several indepentent Java applications, with a loop controlled by shell script... With this I conclude that when the set of Connections are constructed from a single Java application they are not working properly, and when they are constructed from independent java applications, they work as expected. I'd like to know why, so I can make the job using only java!
Alexandre