cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nikita Timofeev (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CAY-2412) SelectQuery with prefetches and cache bring data losing
Date Tue, 06 Mar 2018 13:53:00 GMT

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

Nikita Timofeev commented on CAY-2412:
--------------------------------------

Ok, after further research I'm back to selectFirst() + joint problem but it is much trickier
than direct call.

Here is a small test that reproduces this problem (we have one {{Artist}} with three {{Paintings}}
in DB):
{code:java}
Artist artist0 = ObjectSelect.query(Artist.class)
        .prefetch(Artist.PAINTING_ARRAY.joint())
        .localCache("test")
        .selectOne(context);
assertEquals(3, artist0.getPaintingArray().size());

Artist artist1 = ObjectSelect.query(Artist.class)
        .prefetch(Artist.PAINTING_ARRAY.joint())
        .selectFirst(context);
assertEquals(1, artist1.getPaintingArray().size()); // <-- wrong assertion, but we expect
this

Artist artist2 = ObjectSelect.query(Artist.class)
        .prefetch(Artist.PAINTING_ARRAY.joint())
        .localCache("test")
        .selectOne(context);
assertEquals(3, artist2.getPaintingArray().size()); // <-- assertion failure here, got
1 instead of 3
{code}

Explanation of this test failure:
 * first query returns correct data and goes to cache
 * second query corrupts {{Artist}} state in context
 * third query returns from cache and grabs corrupted {{Artist}} state from shared context

> 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)

Mime
View raw message