尝试在Azure上升级到Postgresql数据库时,上载至少会挂起一个小时,没有任何错误消息。 flask db migrate
运行正常,没有错误或警告
我找到了一些负责锁的引用,但是我发现的似乎表明这不是这里的问题。
重置数据库时,基于SELECT * FROM pg_locks;
的锁如下:
locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath
------------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+-----+-----------------+---------+----------
relation | 14335 | 11577 | | | | | | | | 7/21 | 148 | AccessShareLock | t | t
virtualxid | | | | | 7/21 | | | | | 7/21 | 148 | ExclusiveLock | t | t
(2 rows)
我理解的是指我在其中进行查询的活动pgsql连接。
但是,在运行flask db upgrade
锁变为:
locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid |
objsubid | virtualtransaction | pid | mode | granted | fastpath
---------------+----------+----------+------+-------+------------+---------------+---------+-------+-
---------+--------------------+-----+-----------------------+---------+----------
relation | 14335 | 11577 | | | | | | | | 11/21 | 588 | AccessShareLock | t | t
virtualxid | | | | | 11/21 | | | | | 11/21 | 588 | ExclusiveLock | t | t
relation | 14335 | 18183 | | | | | | | | 9/4 | 140 | AccessShareLock | t | t
relation | 14335 | 18180 | | | | | | | | 9/4 | 140 | AccessShareLock | t | t
relation | 14335 | 2685 | | | | | | | | 9/4 | 140 | AccessShareLock | t | t
relation | 14335 | 2684 | | | | | | | | 9/4 | 140 | AccessShareLock | t | t
relation | 14335 | 3455 | | | | | | | | 9/4 | 140 | AccessShareLock | t | t
relation | 14335 | 2663 | | | | | | | | 9/4 | 140 | AccessShareLock | t | t
relation | 14335 | 2662 | | | | | | | | 9/4 | 140 | AccessShareLock | t | t
relation | 14335 | 2615 | | | | | | | | 9/4 | 140 | AccessShareLock | t | t
relation | 14335 | 1259 | | | | | | | | 9/4 | 140 | AccessShareLock | t | t
virtualxid | | | | | 9/4 | | | | | 9/4 | 140 | ExclusiveLock | t | t
virtualxid | | | | | 8/187 | | | | | 8/187 | 524 | ExclusiveLock | t | t
relation | 14335 | 18210 | | | | | | | | 7/11 | 132 | AccessShareLock | t | t
relation | 14335 | 18209 | | | | | | | | 7/11 | 132 | AccessShareLock | t | t
relation | 14335 | 18207 | | | |
...
relation | 14335 | 24607 | | | | | | | | 9/4 | 140 | ShareRowExclusiveLock | t | f
relation | 14335 | 24607 | | | | | | | | 9/4 | 140 | AccessExclusiveLock | t | f
(58 rows)
flask db upgrade命令输出
INFO [alembic.runtime.migration] Context impl PostgresqlImpl.
INFO [alembic.runtime.migration] Will assume transactional DDL.
INFO [alembic.runtime.migration] Running upgrade db53564bee93 -> 49f15097679f, empty message
然后挂起。
我不知道它为什么挂起,为什么在任何地方都没有错误消息指示为什么要花这么长时间才能应用数据库迁移。我以前能够将迁移应用于相同的数据库,但是现在挂起了。