Thread: waitOnLOck on several threads when db connection lost
Hi,
Basically I'm using Akka with postrgeSQL JDBC API. For those who doesn't know Akka, just know that I have several actors (i.e threads in my case) doing COPY from incoming files. I'm testing the resilience of my system by stopping and restarting the database during processing. My problem is that during restarts, some of my threads (seems random) just stay hanging for a lock..."It appears that you are using the PostgreSQL CopyManager, correct? Looking at QueryExecutorImpl it appears that rollback() is trying to obtain a lock that was not released by the CopyManager. I recommend using the CopyManager.copyIn() method that returns a CopyIn object, rather than using the convenience method that takes a reader. Use the writeToCopy() to pump the data in, and be sure to catch SQLException. If you get an SQLException, call cancelCopy() and retry or whatever your recovery scenario is, otherwise call endCopy(). I would have expected PostgreSQL to handle the severing of a Connection in the middle of a bulk copy better, but that is probably a question for the PostgreSQL group."