Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 370105

Summary: [DB] CommitException: SELECT-statement already in cache
Product: [Modeling] EMF Reporter: Stefan Winkler <stefan>
Component: cdo.dbAssignee: Eike Stepper <stepper>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 Flags: stefan: review? (stepper)
Version: 4.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Stefan Winkler CLA 2012-01-30 05:12:36 EST
I just encountered the following exception with H2 DB in branching-ranges mode:

org.eclipse.emf.cdo.util.CommitException: Rollback in DBStore: org.eclipse.net4j.util.ImplementationError: SELECT cdo_version, cdo_created, cdo_revised, cdo_resource, cdo_container, cdo_feature, name, street, city, categories, suppliers, customers, purchaseOrders, salesOrders FROM model1_Company WHERE cdo_id=? AND cdo_branch=? AND (ABS(cdo_version)=?) already in cache
	at org.eclipse.emf.cdo.server.internal.db.SmartPreparedStatementCache$Cache.put(SmartPreparedStatementCache.java:123)

Reproducible with test case. Will create bug branch to track ...
Comment 1 Stefan Winkler CLA 2012-01-30 06:25:29 EST
The problem was caused by the recursive reading in cascading branches. If a list is modified in a sub-branch and the list values are not yet present in that branch, the list values have to be read from the base branch's revision via a recursive call. The problem was that the caller did not release its own SQL statement to the cache before doing the recursive call. Therefore, for each recursion the same SQL statement was created new (because the cache did not contain it as it was checked out). When checking in, the cache checks if the SQL is already contained in the cache and if so issues the error encountered above. 

The fix was to finish all reading operations and then release the statement to the cache before doing the recursive call. 

Test case and fix available in 

commit 06caef367e263da4cc302a6307841a7e95f0e2bc
Author: Stefan Winkler <stefan@winklerweb.net> 2012-01-26 13:17:38
Committer: Stefan Winkler <stefan@winklerweb.net> 2012-01-30 12:11:47
Parent: 490d2d1752af8e5e8404549a498e335040d19bb1 (Add a missing if(TRACER.isEnabled()) line)
Branches: bugs/370105, origin/bugs/370105
Comment 2 Eike Stepper CLA 2012-04-04 19:30:01 EDT
Stefan, please contact me on Skype (having Git issues...)
Comment 3 Eike Stepper CLA 2012-08-14 22:56:23 EDT
Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master.
Comment 4 Eike Stepper CLA 2012-10-30 08:15:29 EDT
commit cd7c758a5c0887ea43c769c4aa276a3157debe6a
Comment 5 Eike Stepper CLA 2012-10-30 08:16:16 EDT
See also bug 364105.
Comment 6 Eike Stepper CLA 2013-06-27 03:31:33 EDT
Available in R20130613-1157 (4.2)