Re: Select For Update question
От | Barry Lind |
---|---|
Тема | Re: Select For Update question |
Дата | |
Msg-id | 3E81D7F0.2010604@xythos.com обсуждение исходный текст |
Ответ на | Re: Select For Update question (Jean-Christian Imbeault <jc@mega-bucks.co.jp>) |
Список | pgsql-jdbc |
Jean-Christian Imbeault wrote: > I know this is not specifically postgres related, but if my application > crashes after putting a lock on some rows, I have notice that postgres > releases the locks. > > Is the behaviour reliable? I.e. can feel safe in that if my application > crashes any locks it held will be released? > Yes you can rely on this behavior. The only thing that may be unpredictable is when the locks will be released. If the application "crashes" the locks should be cleaned up when the application cleans up its resources in dealing with the "crash" (i.e. rolling back open connections and exiting somewhat gracefully). If however it is a true "crash", such as java seg faulting, or someone killing the process, then the server will detect that the client socket connection was lost and clean up. This may not happen immediately, it may take a while for the server to realize the client is no longer there. This does get a bit more complicated if you are using connection pools. If you have a connection checked out of the pool and your code catches an unexpected exception and continues processing, but forgets to rollback or return the connection to the connection pool, then that connection will remain open and the transaction and locks will not be released. thanks, --Barry
В списке pgsql-jdbc по дате отправления: