|
|
|
|
| Re: SEQUENCE table / row lock issue [message #753519 is a reply to message #748533] |
Thu, 27 October 2011 10:55   |
James Sutherland Messages: 1834 Registered: July 2009 |
Senior Member |
|
|
By default EclipseLink will allocate sequence ids in the current database transaction. If EclipseLink has not yet started a database transaction, then it will start a separate transaction for sequencing (and no locks will be held). EclipseLink does not start the database transaction when you start the JPA transaction, it deferrs it until it has to, so sequencing is normally non locking. If however you call flush() or triggered a flush() from a query, or executed SQL or update JPQL queries, then the database transaction will be started, and sequences acquired after this will hold locks.
You can avoid this be configuring a sequence connection pool, then EclipseLink will use a connection from this pool for sequencing, and never the active transaction.
You can configure a separate connection pool to be used by sequencing using the "eclipselink.connection-pool.sequence.nonJtaDataSource", etc. properties.
See,
http://www.eclipse.org/eclipselink/api/2.3/org/eclipse/persistence/config/PersistenceUnitProperties.html#CONNECTION_POOL_SEQUENCE
James : Wiki : Book : Blog
|
|
|
| Re: SEQUENCE table / row lock issue [message #753521 is a reply to message #748533] |
Thu, 27 October 2011 10:55   |
James Messages: 272 Registered: July 2009 |
Senior Member |
|
|
By default EclipseLink will allocate sequence ids in the current database transaction. If EclipseLink has not yet started a database transaction, then it will start a separate transaction for sequencing (and no locks will be held). EclipseLink does not start the database transaction when you start the JPA transaction, it deferrs it until it has to, so sequencing is normally non locking. If however you call flush() or triggered a flush() from a query, or executed SQL or update JPQL queries, then the database transaction will be started, and sequences acquired after this will hold locks.
You can avoid this be configuring a sequence connection pool, then EclipseLink will use a connection from this pool for sequencing, and never the active transaction.
You can configure a separate connection pool to be used by sequencing using the "eclipselink.connection-pool.sequence.nonJtaDataSource", etc. properties.
See,
http://www.eclipse.org/eclipselink/api/2.3/org/eclipse/persistence/config/PersistenceUnitProperties.html#CONNECTION_POOL_SEQUENCE
--
James : http://wiki.eclipse.org/EclipseLink : http://en.wikibooks.org/wiki/Java_Persistence : http://java-persistence-performance.blogspot.com/
|
|
|
|
|
|
| Re: SEQUENCE table / row lock issue [message #756370 is a reply to message #755241] |
Sat, 12 November 2011 08:26  |
Luca Graf Messages: 17 Registered: September 2011 |
Junior Member |
|
|
Hi James,
i use the eclipselink version bundled with glassfish-3.1.1 (2.3.0.v20110604-r9504).
I have done some futher debuging and it seem's that the SequenceManager uses the wrong allocation strategy (Preallocation_Transaction_NoAccessor_State) also if a sequence connection pool is configured in persistence.xml. The Preallocation_Transaction_NoAccessor_State strategy not use seperate connections for sequence allocation, also it use locks that seems to be the cause for the deadlock.
I have created an issue with a more detailed description and a proposed patch.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=363643
Greetings Luca
P.S. It seems that the old-style (deprecated as of EclipseLink 2.2) configuration 'eclipselink.jdbc.sequence-connection-pool.*' is not affected and can be used as workaround.
[Updated on: Sat, 12 November 2011 08:53] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.07817 seconds