views:

62

answers:

1

I have a Django app that uses MySQL and the InnoDB engine for storage. For some reason, Django sometimes leaves locks in place, even after the query has completed. (I can see them with Innotop).

The only transaction-handling stuff that I do in my code is that I have django.db.transaction.commit_on_success specified for some of my save() methods where I am working with multi-table inheritance.

If I restart the Apache server, the locks go away.

Has anyone seen something like this? Could I have written in some anti-pattern that would cause this?

+1  A: 

The only time I've managed to accomplish this was by setting up "scheduled" tasks in Django that weren't related to requests/views. The default auto-commit transaction handling system only commits transactions when a request/response pair is completed and sent back to the end user, so creating kron-esque jobs that run without a request being sent bypasses that mechanism.

Otherwise it's generally pretty difficult to make it fail to release a lock. You're sure there aren't extremely long-running blocks of code (perhaps relying on an external service that's timing out or something of the sort) tying things up?

Gabriel Hurley