Comment 2 for bug 788592

Revision history for this message
Scott Ritchie (sritchie) wrote : Re: [Bug 788592] [NEW] KeyValue service errors when first creating UserGameProfile

Ok just read the other bug reports - and that seems to indicate what i said
is definately the case.

Looks like we'll need to go and track down wherever a UserGameProfile,
UserAchievement or KeyValuePair is made and make sure that the
persistencemanager isnt kept open between writes.
These three should be the only cases where two objects are created at once.

On Thu, May 26, 2011 at 10:56 PM, Scott Ritchie <email address hidden>wrote:

> I have a feeling i know what the problem is here.
> Can you write a test game where the only functionality is to put a
> KeyValuePair?
>
> If what i suspect is correct;
>
> KeyValuePairs and UserGameProfiles are not in the same entity group - so
> the first time a game is started up, what happens when a call to the
> KeyValuePair service is made is;
>
> PersistenceManager pm = PMF.getManager();
> //lookup UGP, not found so create a new one
> //KVP not found so create a new one
> pm.close()
>
> Since KeyValuePairs and UserGameProfiles are in different entity groups,
> this cant be done as the Google App Engine error indicates.
>
> There are two potential ways around this;
>
> 1) Try closing the PersistenceManager between the two creation calls.
>
> 2) If this doesnt work it would be best to make the relationship between
> UGPs and KeyValuePairs owned (being in an owned relationship forces these
> two datatypes to be in the same entity group)
> The limitation of this is Owned relationships can only handle very simple
> database models, which is why it didnt work for ours initially and we had to
> rewrite the backend to used unowned relationships.
>
>
> On Thu, May 26, 2011 at 10:37 PM, Matt Giuca <email address hidden>wrote:
>
>> Public bug reported:
>>
>> I'm not quite sure what's happening now. This doesn't happen in my API
>> test, but in one of the student games. The game makes many requests to
>> the KeyValue service while it is starting up (perhaps that's the
>> difference -- APITest only makes requests after some length of time).
>>
>> Every one of the requests fails with a server error, but this only
>> happens the first time a user plays that particular game. On all
>> subsequent plays, it is fine.
>>
>> The message on the server is:
>> Caused by: javax.jdo.JDOFatalUserException: Illegal argument
>> NestedThrowables: java.lang.IllegalArgumentException: can't operate on
>> multiple entity groups in a single transaction. found both Element { type:
>> "UserGameProfileData" id: 389 } and Element { type: "GameData" id: 3 }
>> at
>> au.edu.unimelb.csse.mugle.server.model.KeyValuePairGetter.getKeyValuePair(KeyValuePairGetter.java:51)
>> at
>> au.edu.unimelb.csse.mugle.server.api.KeyValueServiceImpl.get(KeyValueServiceImpl.java:58)
>>
>> ** Affects: mugle
>> Importance: Critical
>> Assignee: Matt Giuca (mgiuca)
>> Status: In Progress
>>
>>
>> ** Tags: datastore
>>
>> --
>> You received this bug notification because you are subscribed to MUGLE.
>> https://bugs.launchpad.net/bugs/788592
>>
>> Title:
>> KeyValue service errors when first creating UserGameProfile
>>
>> Status in Melbourne University Game-based Learning Environment:
>> In Progress
>>
>> Bug description:
>> I'm not quite sure what's happening now. This doesn't happen in my API
>> test, but in one of the student games. The game makes many requests to
>> the KeyValue service while it is starting up (perhaps that's the
>> difference -- APITest only makes requests after some length of time).
>>
>> Every one of the requests fails with a server error, but this only
>> happens the first time a user plays that particular game. On all
>> subsequent plays, it is fine.
>>
>> The message on the server is:
>> Caused by: javax.jdo.JDOFatalUserException: Illegal argument
>> NestedThrowables: java.lang.IllegalArgumentException: can't operate on
>> multiple entity groups in a single transaction. found both Element { type:
>> "UserGameProfileData" id: 389 } and Element { type: "GameData" id: 3 }
>> at
>> au.edu.unimelb.csse.mugle.server.model.KeyValuePairGetter.getKeyValuePair(KeyValuePairGetter.java:51)
>> at
>> au.edu.unimelb.csse.mugle.server.api.KeyValueServiceImpl.get(KeyValueServiceImpl.java:58)
>>
>
>