Tombatron
Tombatron

Reputation: 1347

Making SQL Alchemy Play Nice With Google App Engine

I'm currently working on a Google App Engine (Python) project which primarily uses Google Cloud SQL (with SQL Alchemy) for back-end data storage.

Most of the time everything works perfectly well. However, occasionally "something" goes haywire and we start getting bizarre exceptions. For example:

We think this might be related to the spinning up of a new GAE instance, but we can't really be sure.

With all that being said, my question is this. What are some strategies that my team and I can use to track down this issue?

Keep in mind that the application is running on Google App Engine so that might limit our options a bit.

Update: Owen Nelson's comment below is right on. We've added threading.RLock as suggested by Google. However we are still seeing this issue, but much less often.

I want to be clear, to this point we've been unable to reproduce this issue in our local environment. We are pretty sure this has something to do with dynamic instances spinning up and that isn't something that we can really do in development.

Upvotes: 4

Views: 559

Answers (1)

David Dugué
David Dugué

Reputation: 165

From what I can understand, your application have problems only in production mode.

Try to reproduce the bug in dev mode

The best possible solution would be to be able to reproduce that bug in development mode. To do that, you could try to run a batch of unittest with LOTS of data. (See how to do local test on appengine).

If that doesn't work...

Turn on appstats to get more information on the handler

You can turn on appstats to try and get information on which handler is currently causing the problem. Appstats normally gives you information on datastore, this is not relevant in our case, but you can get information from the requests in general (such as response time)

Identify the handler and wrap it in a beautiful try catch

Once you identify the source of the problem or from where it is raised, you can surround it with a try..catch.. With that you can get more information on the current execution Trace and hopefully solve your problem

Upvotes: 1

Related Questions