Django 1.7迁移挂起 [英] Django 1.7 Migrations hanging

查看:81
本文介绍了Django 1.7迁移挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试申请django迁移。它做的很好(很小,只向两个不同的模型添加了 CharField 。但是,当我运行实际的迁移时,它挂起了(没有失败,没有成功,只能坐下来)



通过谷歌搜索,我发现其他打开的连接可能会使其混乱,因此我重新启动了数据库。但是,该数据库已连接到持续运行的作业,新查询确实潜行了



还有什么其他的吗?



还有什么其他的吗?

解决方案

至少在PostgreSQL中,您不能修改表(即使只是添加新列)虽然有活跃的交易,但最简单的解决方法通常是:




  • 运行迁移脚本(将挂起)

  • 重新启动Web服务器/ wsgi容器



重新启动y我们的网络服务器将中止所有未完成的交易(假设您没有同时打开交易的后台进程),因此,一旦没有交易阻止您的表,迁移便会完成。


I have a django migration I am trying to apply. It gets made fine (it's small, it's only adding a CharField to two different Models. However when I run the actual migrate it hangs (no failure, no success, just sits).

Through googling I've found that other open connections can mess with it so I restarted the DB. However this DB is connect to continuously running jobs and new queries do sneak in right away. However they are small, and last time I tried restarting I THINK I was able to execute my migrate before anything else. Still nothing.

Are there any other known issues that cause something like this?

解决方案

At least in PostgreSQL you cannot modify tables (even if it's just adding new columns) while there are active transactions. The easiest workaround for this is usually to:

  • run the migration script (which will hang)
  • restart your webserver/wsgi container

When restarting your webserver all open transactions will be aborted (assuming you don't have background processes which also have transactions open), so as soon as no transactions are blocking your table, the migration will finish.

这篇关于Django 1.7迁移挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆