[hibernate-dev] lock timeout support

Steve Ebersole steve at hibernate.org
Fri Jun 1 07:44:48 EDT 2012


On Fri 01 Jun 2012 05:27:12 AM CDT, Strong Liu wrote:
> Hi there,
>
> I'm working on this org.hibernate.ejb.test.lock.LockTest#testFindWithPessimisticWriteLockTimeoutException test, it failed on lots of DBs
>
> for now, I found:
>
> sql server : supports nowait, but not other lock timeout value
> DB2 : doesn't support either
> sybase: doesn't support either
>
> by "doesn't support" I mean, can't set this timeout from sql statement level, but they do support set it as a DB global config.

Sybase at least supports it as a connection-level setting as well.  Do 
the rest?  The idea being that we could set and reset that connection 
setting as the means to specify lock timeout.  Practically though that 
means they would also have to expose a way to read the current setting 
value so that we knew what to reset to.

>
> so, I'm wondering if we could choose this way:
>
> 1. if DB supports both, then good
> 2. if DB supports nowait only, and lock timeout is set to nowait, then good
> 2.1 if lock timeout is set to 5 milliseconds, for example, then we setQueryTimeout(1) // (locktimeout +500)/1000+1

I think with your 2.1 we just need to be careful when the user has 
specified a query timeout already.

> 3. if DB doesn't supports either, then same as 2.1, use java.sql.Statement#setQueryTimeout

Set to what?  Just some really low number?


> does this acceptable? or we just ignore lock timeout if the underlying Db doesn't support it?

The only possible outcomes if we cannot apply the requested lock 
timeout in any manner is to (a) error or (b) ignore.  Ignoring makes 
lock timeout more of a hint than a requirement.  Thats the fundamental 
question we need to answer here.   Don't know the answer, just 
re-stating the question.

--
steve at hibernate.org
http://hibernate.org


More information about the hibernate-dev mailing list