Re: MVCC=true, multi-thread and ReentrantLock

2013-02-27 Thread Noel Grandin
On Wed, Feb 27, 2013 at 9:23 PM, Thomas Mueller 
thomas.tom.muel...@gmail.com wrote:

 . And just replacing synchronized with ReentrantLock wouldn't really help
 much.


Depends on how hard the lock is being contended. If a lock is heavily
contended, the fairness property of ReentrantLock would be very useful.

-- 
You received this message because you are subscribed to the Google Groups H2 
Database group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




MVCC=true, multi-thread and ReentrantLock

2013-02-26 Thread Noel Grandin

HI

Since we now require Java1.5, perhaps we should be using

 java.util.concurrent.locks.ReentrantLock(true/*fair*/)

  (note  the use of the fairness parameter.)

instead of using the synchronized keyword?

I suspect it would reduce the incidence of  Timeout trying to lock 
table when using MVCC mode, because we'd be executing the incoming 
queries in the order in which they arrived, instead of in semi-random order.


Personally, I don't use MVCC or MULTI_THREADED, so I'm not inclined to 
pursue this, but other people seem to be using those modes, so maybe 
they'd like to try?


Regards,
Noel Grandin

Specifically, in the code I talking about here lives in 
org.h2.command.Command


public int executeUpdate() {
Object sync = database.isMultiThreaded() ? (Object) session : 
(Object) database;


synchronized (sync) {
   
}
}

private long filterConcurrentUpdate(DbException e, long start) {
   
database.wait(sleep);
   
}


and in org.h2.table.RegularTable

private void doLock(Session session, int lockMode, boolean exclusive) {
   
database.wait(sleep);
   
}

and in org.h2.mvstore.db.MVTable#doLock(Session session, int lockMode, 
boolean exclusive)

and in org.h2.mvstore.db.MVStore.Writer#run()



--
You received this message because you are subscribed to the Google Groups H2 
Database group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.