*** CORRECTION ***

I'm doing an insert, not an update, so that block should read:

Foo foo = new Foo();
foo.setBar(1);
pm.makePersistent(foo);

// exception fires

tx.commit





On Mar 18, 12:00 am, Blake <[email protected]> wrote:
> A bug in my code sent my tasks out of control, so I'm temporarily at
> my limit for the day.  One of my database inserts is in a transaction
> that kicks off a task, per instructions here:
>
> http://code.google.com/appengine/docs/java/taskqueue/overview.html#Ta...
>
> As expected, the task queuing failed because of my quota issues, but
> my database insert succeeded.  This isn't good.
>
> I verified that I'm calling rollback on my transaction, but my record
> it still making it to the database.  What am I doing wrong!?!?
>
> here's the basic logic:
>
> Transaction tx = pm.currentTransaction();
> try{
>     tx.begin()
>
>     Foo foo = pm.getObjectById(...)
>     foo.setBar(1);
>     pm.makePersistent(foo);
>
>     // queue up task (throws an exception)
>
>     tx.commit();}
>
> finally
> {
>     if(tx.isActive())
>     {
>          // i verified that this is happening with a log statement
>          tx.rollback();
>     }
>
> }
>
> I verified that rollback is happening with a lot statement in that
> last block, but like I said, the database gets the record.  My
> temporary fix will be to try to queue up the task before committing
> the record to the database, but then I'm relying on the task killing
> itself later on when a database exception occurs.
>
> Am I using transactions wrong?

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

Reply via email to