MyBatis Hanging?

803 views
Skip to first unread message

Rob Ogilvie

unread,
Jul 9, 2010, 2:51:04 PM7/9/10
to mybati...@googlegroups.com
List,

I seem to have encountered an odd situation in which MyBatis is hanging.  It's working fine for select statements, but the update statement I'm calling is hanging.  I set the timeout to 2000 on the update to ensure it wasn't the database hanging.

Is there a good place to start troubleshooting this?  I walked through the code in debug mode and it hits the mapper.updateInfo(updatedObject) and sits there forever; the servlet handler timed out 28 minutes, 33 seconds later and returned nothing to the client.

Rob

Rob Ogilvie

unread,
Jul 9, 2010, 4:42:54 PM7/9/10
to mybati...@googlegroups.com
I appear to have stumbled upon a bug, but would like confirmation before I report it to a bug tracker.

The cause of the problem is I had a different session locking the table I was trying to update.  I believe the timeout of 2000 should have caused a failure in the event of a lock that doesn't clear within the timeout... shouldn't it?

Rob

Rob Ogilvie

unread,
Jul 9, 2010, 4:43:04 PM7/9/10
to mybati...@googlegroups.com
....Oracle, BTW.

Clinton Begin

unread,
Jul 10, 2010, 10:11:19 AM7/10/10
to mybati...@googlegroups.com
Timeout may not work for update statements on many RDBMS.  A lot of databases support putting the timeout directly in the SQL though.

Is there any way you can confirm this behavior with a select statement?

Clinton

Rob Ogilvie

unread,
Jul 11, 2010, 11:37:04 PM7/11/10
to mybati...@googlegroups.com
I can't think of a way to lock a resource against SELECT statements in Oracle.

Ideally, MyBatis should implement its own timeout, shouldn't it?

Rob

Rob Ogilvie

unread,
Jul 12, 2010, 9:45:59 AM7/12/10
to mybati...@googlegroups.com
If an update locks some resources, they're locked for writing.  A select on those resources will show you the pre-update version (until you commit, at which point it will show you the post-update version) of the data.

Rob



On Mon, Jul 12, 2010 at 01:50, Giovanni Cuccu <giovann...@gmail.com> wrote:
Hi,
   correct me if I'm wrong but a select for update locks resources,
and if I remerember correctly even a select on a Oracle RAC system may
lock some resources.
I'm using Oracle and the statement timeout property works as expect
even when there are waitings related to database locks.
ciao,
   Giovanni

Larry Meadors

unread,
Jul 12, 2010, 10:08:52 AM7/12/10
to mybati...@googlegroups.com
No, "select for update" in Oracle is a different animal - it locks the
rows until the next rollback or commit.

Larry

Giovanni Cuccu

unread,
Jul 12, 2010, 10:16:32 AM7/12/10
to mybati...@googlegroups.com
Yes, and it's not an Oracle specific feature, see
http://www.postgresql.org/docs/8.1/static/sql-select.html#SQL-FOR-UPDATE-SHARE
for an example.
Giovanni

--------------------------------------------------------------------
"You don't know the power of dark side" - Darth Vader

Rob Ogilvie

unread,
Jul 12, 2010, 10:42:30 AM7/12/10
to mybati...@googlegroups.com
Is that what you would like tested?  A SELECT FOR UPDATE doesn't lock it for SELECT statements... only for writing actions.  As far as I know, there's no way to lock a table for read operations in Oracle.

Rob

Giovanni Cuccu

unread,
Jul 12, 2010, 10:59:46 AM7/12/10
to mybati...@googlegroups.com
yes, you're right, there is no way to prevent a lock for read other
than select for update.
in one of your email you said

The cause of the problem is I had a different session locking the
table I was trying to update. I believe the timeout of 2000 should
have caused a failure in the event of a lock that doesn't clear within
the timeout... shouldn't it?

What I understood is that you were expecting to statementTimeout to
work properly and raise an exception when different locks on the table
were preventing the update within n seconds.
If so I can say that with version 2 of MyBatis the I experienced a
timeout in the situation you described when using the statementTimeout
property.
I have configured it in productions systems ad sometimes we see an
oracle error reporting the cancel of the operation caused by the
timeout.
If I did understand your problem the cause does not seems a Mybatis
bug, so you should create a simple test case and someone on the list
can try to reproduce it and check if it's a bug or not.
ciao,
Giovanni

--------------------------------------------------------------------
"You don't know the power of dark side" - Darth Vader

Reply all
Reply to author
Forward
0 new messages