I have only seen problems with getObjectById() (running threadsafe for
two months), as per 
http://code.google.com/p/googleappengine/issues/detail?id=4834.
I tried the "initialize with a synchronized dummy query" but didn't
have much luck with it.

In the meantime I've created wrapper methods that let me switch
between using getObjectById(), and using a query by key. No other
changes - no synchronization of anything, including the
PersistenceManager. e.g.:

static private final boolean QUERY = true;

...

 static public MyEntity getMyEntityById(PersistenceManager pm, Key
key) {

    MyEntity e = null;
    if (!QUERY) {
      e = pm.getObjectById(MyEntity.class, key);
    } else {
      final Query query = pm.newQuery(MyEntity.class);
      query.setFilter("key == targetKey");
      query.declareParameters("String targetKey");
      final String keyStr = KeyFactory.keyToString(key);
      final List<MyEntity> results = (List<MyEntity>)
query.execute(keyStr);
      if (results.size() != 0) {
        e = results.get(0);
      }
      if (e == null) {
        throw new AppException(FaultCodes.FAULT_OBJECT_NOT_FOUND,
            "Entity not found");
      }

    }
    return e;

  }

No issues with threadsafety for the query method and I can switch back
to getObjectById() easily to test if it's been fixed.

I haven't seen any issues so far (knock on wood) with writes or
deletes, even under high load - only with reads via getObjectById().

/Tom

On Jun 23, 6:12 pm, David <turntwo...@gmail.com> wrote:
> Aaron (or others),
>
> Do you have any updates from your experiences using JDO with
> threadsafe enabled?  Has your synchronization changes eliminated these
> errors?  Is it necessary to synchronize reads such as query.execute
> and pm.detachCopyAll in additional to the write operations such as
> pm.deletePersistent and pm.makePersistent?
>
> Thank you,
> David
>
> On May 17, 4:51 pm, Aaron Shepherd <ans...@onfast.com> wrote:
>
> > Ok. My change to PMF.java to synchronize the get of the
> > PersistenceManager did NOT correct the problem.
>
> > Going to fallback to synchronizing every usage of the
> > PersistenceManager (reads and writes). <sigh/>
>
> > Will update this issue with any further results.
>
> > On May 17, 1:54 am, Stephen Johnson <onepagewo...@gmail.com> wrote:
>
> > > Ah, I missed the point about it being tasks and didn't realize the
> > > threadsafe only applied to user requests and not  tasks. If indeed that 
> > > was
> > > the case.
>
> > > On Mon, May 16, 2011 at 10:44 PM, Juha K <juha.kosk...@gmail.com> wrote:
> > > > The datanucleus issue has a comment "Then, when my tasks run in 
> > > > parallel,
> > > > initialisation has already been done and the problem doesn't appear any
> > > > more.", so before the threadsafe property, only tasks were run in 
> > > > parallel.
> > > > Probably that's why I didn't see this error before, I didn't have tasks
> > > > doing db access.
>
> > > > --
> > > > You received this message because you are subscribed to the Google 
> > > > Groups
> > > > "Google App Engine for Java" group.
> > > > To post to this group, send email to
> > > > google-appengine-java@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > google-appengine-java+unsubscr...@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/google-appengine-java?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to