Is there some way to pause before retrying the database transaction? If you don't, then it seems to me that the processes that are banging into each other are going to keep failing. I'd like to add a pause for a random amount of time in the catch block.
leszek wrote: > http://code.google.com/intl/pl/appengine/docs/java/datastore/transactions.html > > Look at the next code snippet > > =========== > for (int i = 0; i < NUM_RETRIES; i++) { > pm.currentTransaction().begin(); > > ClubMembers members = pm.getObjectById(ClubMembers.class, > "k12345"); > members.incrementCounterBy(1); > > try { > pm.currentTransaction().commit(); > break; > > } catch (JDOCanRetryException ex) { > if (i == (NUM_RETRIES - 1)) { > throw ex; > } > } > } > ============ > > In Google App Engine "optimistic" transaction model is applied. There > is no any "global block", every request starts transaction but only > one is allowed to run through it, the second and next get and > exception and should run some logic to handle this exception. Here it > tries to rerun the transaction (hoping that the first already has > finished it) You can also return error message to the client and > enable switch "try again" or any other rescue plan. > --~--~---------~--~----~------------~-------~--~----~ > 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 [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-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 [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-java?hl=.
