开发者

why is django leaving locks behind in mysql?

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 woul开发者_运维百科d cause this?


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜