Bug 363643 - Sequence connection-pool configuration in persistence.xml will not be used
Summary: Sequence connection-pool configuration in persistence.xml will not be used
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P2 normal with 4 votes (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-12 08:23 EST by Luca Graf CLA
Modified: 2022-06-09 10:29 EDT (History)
1 user (show)

See Also:


Attachments
patch (804 bytes, patch)
2011-11-12 08:24 EST, Luca Graf CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Luca Graf CLA 2011-11-12 08:23:27 EST
If a seperate sequence connection pool is configured through the 'eclipselink.connection-pool.sequence.*' attribute(s) in the persistence.xml, it will not be used.

It seem's that the SequenceManager use the wrong allocation strategy (Preallocation_Transaction_NoAccessor_State) also if a sequence connection pool is configured in persistence.xml.

I think the origin lies in the implementation of the EntityManagerSetupImpl.updateConnectionSettings method which not set the SequencingControl.setShouldUseSeparateConnection flag to true. That causing that the connectionHandler will be set to null in the SequencingManager.onConnectInternal method. If connectionHandler is set to null the wrong strategy (Preallocation_Transaction_NoAccessor_State) will be used instead of Preallocation_Transaction_Accessor_State.


I added a patch that sets the setShouldUseSeparateConnection flag in the EntityManagerSetupImpl.updateConnectionSettings. Iam not sure if this causing any unwanted side effects. But maybe it can be used as a starting point for a developer with more insights.

Greeting 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.
Comment 1 Luca Graf CLA 2011-11-12 08:24:10 EST
Created attachment 206893 [details]
patch
Comment 2 Luca Graf CLA 2011-11-12 09:17:18 EST
Build Identifier: 2.3.0.v20110604-r9504

Reproducible: Always

Steps to Reproduce:
1. Add the property 'eclipselink.connection-pool.sequence.nonJtaDataSource' that points to a valid datasource to persistence.xml.
2. Set eclipselink.logging.level to FINEST in persistent.xml.
3. Execute code that needs sequence allocation (f.e. persist an entity that use table sequencing for the id field).
4. You can see that the default connection pool is used for sequence alocation in the log. 
Something like:
...
Connection acquired from connection pool [default].
FINEST: Execute query DataModifyQuery(name="SEQUENCE" sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + #PREALLOC_SIZE WHERE SEQ_NAME = #SEQ_NAME")
FINEST: reconnecting to external connection pool
FINE: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
	bind => [50, SEQ_GEN]
FINEST: Execute query ValueReadQuery(name="SEQUENCE" sql="SELECT SEQ_COUNT FROM SEQUENCE WHERE SEQ_NAME = #SEQ_NAME")
FINE: SELECT SEQ_COUNT FROM SEQUENCE WHERE SEQ_NAME = ?
	bind => [SEQ_GEN]
FINEST: local sequencing preallocation for SEQ_GEN: objects: 50 , first: 1, last: 50
...
Comment 3 Tom Ware CLA 2011-11-24 15:26:38 EST
Setting target and priority.  See the following page for the meanings of these fields:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines

Community: Please vote for this bug if it is important to you.  Votes are one of the main criteria we use to determine which bugs to fix next.
Comment 4 Eclipse Webmaster CLA 2022-06-09 10:15:53 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:29:51 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink