From: Edward C. (JIRA) <no...@at...> - 2006-03-31 00:06:15
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HB-1246?page=comments#action_22664 ] Edward Costello commented on HB-1246: ------------------------------------- If your've got as many sessions open as the database connection limit I'm going to guess you either have a connection leak or you're spawning a new thread for each request. If it's the later case then I'd suggest you consider a Thread pool such as http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/PooledExecutor.html avaliable for download at http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html If you set the size of the thread pool below the size of your connection pool you won't ever hit this deadlock problem. It will of couse limit the concurrent requests to the size of the thread pool but will cause the application to degrade more gracefully (i.e. slowing down rather than cannot get a connection errors) under load. > HILO id can cause deadlock > -------------------------- > > Key: HB-1246 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HB-1246 > Project: Hibernate2 > Type: Bug > Components: core > Versions: 2.1.6 > Environment: HILO id generation with a fixed connection limit > Reporter: Edward Costello > > > The HILO generator attempts to obtain a connection to the database in addition to the one being used by the current session. If no connections are available and all sessions are attempting an operation that requires ID generation, this will result in deadlock (at least until the connection pool times out the request and the exception kills one of the requesting sessions). > The simple case to observe this effect is: > 1) Set up the connection pool to provide only a single connection. > 2) Attempt to save an object using HILO id generation. > This issue can also occur when there is more than one connection available. > E.G if there are 5 connections, 5 threads open a session, all 5 attempt to save. All 5 threads will be blocked while they each try and obtain a connection for the id generator. > --- Code to Reproduce --- > Configuration cfg = new Configuration(); > cfg.configure(......); // Configured Pool must only allow 1 connection > SessionFactory sf = cfg.buildSessionFactory(); > Session s = sf.openSession(); > Transaction tx = s.beginTransaction(); > s.save(new PersistedObject()); > tx.commit(); > ---- Suggested Resolution --- > The best solution we have come up with is to allow for the configuration of a second smaller connection pool that is used exclusively for HILO (and any other generation types requiring a separate connection). > This pool would be optional and if not specified the main pool would be used (i.e. the current behaviour). -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |