I should also mention that you have this exact same problem with any transactional datastore, including Oracle. The database guarantees integrity of the commit, it doesn't guarantee your code will be notified of it.
Jeff On Wed, Sep 21, 2011 at 1:10 PM, Jeff Schnitzer <[email protected]> wrote: > My sense of this is that unless your transaction is idempotent, the > only kind of exception that is safe to catch & retry in a transaction > is the ConcurrentModificationException (or whatever the equivalent is > in python). Any other exception represents some sort of "real" error > and should either be surfaced to the user or trigger some deep > evaluation of state. > > I just surface it to the user and let them figure it out. > > Jeff > > On Wed, Sep 21, 2011 at 11:31 AM, Brian Olson <[email protected]> wrote: >> I'm trying to figure out and diagnose an odd problem, and my best guess so >> far is that a datastore transaction successfully stored data and also >> returned an error message. >> (I happen to be using Python, but this might be a general datastore issue) >> The code goes about like this: >> >> txn(key): >> x = db.get(key) >> x.foo += 1 >> x.put() >> logging.info('go!') >> # transactionally enqueue something to a task-queue >> return >> foo(key): >> while True: >> try: >> db.run_in_transaction(txn, key) >> except Exception, e: >> logging.exception('ouch') >> time.sleep(10.0) # wait 10 seconds >> continue # fast inline retry >> else: >> return >> >> What I'm seeing is that there was one logged exception: >> "The datastore operation timed out, or the data was temporarily >> unavailable." >> The 'go!' line is logged twice, each time through the transaction, x.foo is >> incremented twice and the task-queue task runs once. >> >> What really bugs me is that x.foo added 2 where I wanted to add 1. >> What really bugs me after that is that it seems that the datastore part of >> the transaction seems to have run twice while the task-queue part of the >> transaction seems to have run once. >> Another thing that bugs me, but I'm kinda coming to terms with it, is that a >> transaction can complete successfully and the API still returns an error. I >> suppose this was always possible if all the actions happened on the >> datastore server machine but then the connection to the appengine instance >> died and never got notified that the transaction happened. The data may be >> safe and consistent, but it makes my logical flow of programming around the >> operation messier. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google App Engine" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/google-appengine/-/Ay0pmrE4720J. >> 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. >> > -- 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.
