[ 
https://issues.apache.org/jira/browse/CAY-2412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16387667#comment-16387667
 ] 

Andrus Adamchik edited comment on CAY-2412 at 3/6/18 12:05 PM:
---------------------------------------------------------------

If Nikita's assessment is right, then switching to "disjoint by id" prefetch 
should fix the issue. Here is a piece of advice buried deep inside prefetch 
docs:

 

??The advantage of  [disjointy by id] prefetch is that matching database rows 
by ID may be much faster than matching the qualifier of the original query. 
Moreover this is the only type of prefetch that can handle SelectQueries with 
fetch limit. Both joint and regular disjoint prefetches may produce invalid 
results or generate inefficient fetch-the-entire table SQL when fetch limit is 
in effect.??


was (Author: andrus):
If Nikita's assessment is right, then switching to "disjoint by id" prefetch 
should fix the issue.

> SelectQuery with prefetches and cache bring data losing
> -------------------------------------------------------
>
>                 Key: CAY-2412
>                 URL: https://issues.apache.org/jira/browse/CAY-2412
>             Project: Cayenne
>          Issue Type: Bug
>          Components: Core Library
>    Affects Versions: 4.0.B1
>         Environment: bootique 0.23
> bootique-jetty 0.23
> bootique-jcache 0.23
> bootique-cayenne 0.23
> cayenne-server 4.0.B1
>            Reporter: Artyom Kravchenko
>            Assignee: Nikita Timofeev
>            Priority: Minor
>
> SelectQuery with prefetches and cache bring data losing
> Object model looks like:
>  
> {code:java}
> COURSE OneToMany COURSE_CLASSES
> COURSE_CLASSES ManyToOne COLLEGE
> COURSE_CLASSES OneToMany SESSIONS
> COURSE_CLASSES ManyToOne ROOM
> ROOM ManyToOne SITE 
> {code}
>  
> Select query looks like:
> {code:java}
> List<Course> courses = ObjectSelect.query(Course.class)
> .where(Course.CODE.eq(code)) 
> .prefetch(Course.COURSE_CLASSES.joint()) 
> .prefetch(Course.COURSE_CLASSES.dot(CourseClass.COLLEGE).joint()) 
> .prefetch(Course.COURSE_CLASSES.dot(CourseClass.SESSIONS).joint())
> .prefetch(Course.COURSE_CLASSES.dot(CourseClass.ROOM).joint()) 
> .prefetch(Course.COURSE_CLASSES.dot(CourseClass.ROOM).dot(Room.SITE).joint()) 
> .cacheStrategy(LOCAL_CACHE) 
> .cacheGroup(Course.class.getSimpleName()) 
> .selectOne(context);
> {code}
>  where 
>  
> {code:java}
> context
> {code}
>  
> is shared readonly  instance of cayenne context. It is also used for other 
> queries inside our application.
>  
> When I iterate through result list 
> {code:java}
> courses.get(i).getCourseClasses(){code}
> I see that list of related CourseClasses is trimmed (doesn't contains full 
> set of records which expected, some records just lost).
> I am not sure who is blame on it
>  - is it prefetch semantic (I have found similar but not exact the same bug 
> CAY-2257)
>  - some concurrent modifications of related objects list (since we load it in 
> shared context)
>  - any caching  issues (we are using JCache/HECache implementation)
> In additional I can say that we are not limited number of cache entries for 
> any cache group, just use 10 min expiry timeout.
> But the main difficulties that I can not reproduce such behaviour locally 
> (reproducible on production environment only) so I can not write clear test 
> for this issue.
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to