Django Postgis更新永远挂起
我正在使用Django和Postgis开发一个web应用程序。在我的测试环境中,我运行了一个南模式迁移,将Django Postgis更新永远挂起,django,postgresql,geospatial,postgis,Django,Postgresql,Geospatial,Postgis,我正在使用Django和Postgis开发一个web应用程序。在我的测试环境中,我运行了一个南模式迁移,将denorm\u locs=MultiPointField(null=True)添加到模型中(将一个新列添加到DB表),然后进行数据迁移以填充新字段。以下是数据迁移: # -*- coding: utf-8 -*- from south.utils import datetime_utils as datetime from south.db import db from south.v2
denorm\u locs=MultiPointField(null=True)
添加到模型中(将一个新列添加到DB表),然后进行数据迁移以填充新字段。以下是数据迁移:
# -*- coding: utf-8 -*-
from south.utils import datetime_utils as datetime
from south.db import db
from south.v2 import DataMigration
from django.db import models
from django.contrib.gis.geos import MultiPoint
import time
class Migration(DataMigration):
def forwards(self, orm):
"Write your forwards methods here."
# Note: Don't use "from appname.models import ModelName".
# Use orm.ModelName to refer to models in this application,
# and orm['appname.ModelName'] for models in other applications.
i = 0
batch_size = 10
start = time.time()
print 'Start: %s' % start
cont = True
while cont:
id_list = orm.MyModel.objects.filter(denorm_locs__isnull=True).order_by('id').values_list('id', flat=True)[:batch_size]
id_list = list(id_list)
print 'Got id_list (%s ids): %s' % (len(id_list), time.time() - start,)
if len(id_list) < batch_size:
cont = False
for mymodel_id in id_list:
locs = [
l.loc
for l in orm.Location.objects.filter(mymodel3__mymodels__id=mymodel_id)
if l.loc
]
mp = MultiPoint(locs)
orm.MyModel.objects.filter(id=mymodel_id).update(denorm_locs=mp)
i += 1
print '%s batches of %s completed' % (i, batch_size,)
您仍然可以看到昨晚的另一个查询从未完成
这里是SELECT relation::regclass,*来自未授权的pg_锁代码>:
relation | locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath
----------+---------------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+------+-----------+---------+----------
| transactionid | | | | | | 14771737 | | | | 5/11758 | 2744 | ShareLock | f | f
(1 row)
relation | locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath
------------------------------------------------------------+---------------+----------+----------+-------+-------+------------+---------------+---------+-------+----------+--------------------+------+------------------+---------+----------
pg_locks | relation | 16388 | 11090 | | | | | | | | 3/39008 | 3658 | AccessShareLock | t | t
| virtualxid | | | | | 3/39008 | | | | | 3/39008 | 3658 | ExclusiveLock | t | t
core_mymodel_mymodel3s | relation | 16388 | 19314 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel3 | relation | 16388 | 19386 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_location | relation | 16388 | 19243 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_denorm_locs_id | relation | 16388 | 2725185 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_title_index | relation | 16388 | 2700114 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_detail_html_index | relation | 16388 | 2700113 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
title | relation | 16388 | 2645243 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_mymodel5_id_6dce956e264c19df_uniq | relation | 16388 | 2576203 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_mymodels_query | relation | 16388 | 2484701 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_mymodel2_id | relation | 16388 | 333698 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_mymodel4_id | relation | 16388 | 302491 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_mymodel5_id | relation | 16388 | 302490 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_start_date | relation | 16388 | 302487 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_end_date | relation | 16388 | 302483 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_pkey | relation | 16388 | 302308 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel | relation | 16388 | 19293 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
| virtualxid | | | | | 4/44 | | | | | 4/44 | 2241 | ExclusiveLock | t | t
core_mymodel_mymodel3s | relation | 16388 | 19314 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel3 | relation | 16388 | 19386 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_location | relation | 16388 | 19243 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_denorm_locs_id | relation | 16388 | 2725185 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_title_index | relation | 16388 | 2700114 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_detail_html_index | relation | 16388 | 2700113 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
title | relation | 16388 | 2645243 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_mymodel5_id_6dce956e264c19df_uniq | relation | 16388 | 2576203 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_mymodels_query | relation | 16388 | 2484701 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_mymodel2_id | relation | 16388 | 333698 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_mymodel4_id | relation | 16388 | 302491 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_mymodel5_id | relation | 16388 | 302490 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_start_date | relation | 16388 | 302487 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_end_date | relation | 16388 | 302483 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_pkey | relation | 16388 | 302308 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel | relation | 16388 | 19293 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
| virtualxid | | | | | 5/11758 | | | | | 5/11758 | 2744 | ExclusiveLock | t | t
core_mymodel_mymodel4_id | relation | 16388 | 302491 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodel3s_pkey | relation | 16388 | 302312 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel_mymodel3s_mymodel_id_5dcd946e263a391f_uniq | relation | 16388 | 302310 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel_start_date | relation | 16388 | 302487 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
| transactionid | | | | | | 14771737 | | | | 4/44 | 2241 | ExclusiveLock | t | f
core_location_loc_id | relation | 16388 | 302470 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel3_pkey | relation | 16388 | 302361 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_end_date | relation | 16388 | 302483 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_pkey | relation | 16388 | 302308 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel3_name | relation | 16388 | 333705 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_denorm_locs_id | relation | 16388 | 2725185 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_title_index | relation | 16388 | 2700114 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel3_name_129459df841fd9de_uniq | relation | 16388 | 333668 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel | tuple | 16388 | 19293 | 93104 | 3 | | | | | | 5/11758 | 2744 | ExclusiveLock | t | f
core_mymodel3_location_id | relation | 16388 | 302517 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel3_name_index | relation | 16388 | 2700014 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_mymodel5_id | relation | 16388 | 302490 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodel2_id | relation | 16388 | 333698 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_mymodel5_id_6dce956e264c19df_uniq | relation | 16388 | 2576203 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodel3s_mymodel_id | relation | 16388 | 302488 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel3_address_id | relation | 16388 | 302516 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel3_mymodel2_id | relation | 16388 | 333704 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel | relation | 16388 | 19293 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_location_pkey | relation | 16388 | 302276 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_mymodel3s_mymodel3_id | relation | 16388 | 302489 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
title | relation | 16388 | 2645243 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_detail_html_index | relation | 16388 | 2700113 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodels_query | relation | 16388 | 2484701 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_location_pkey | relation | 16388 | 302276 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel_mymodel3s_mymodel3_id | relation | 16388 | 302489 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
title | relation | 16388 | 2645243 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_detail_html_index | relation | 16388 | 2700113 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_mymodels_query | relation | 16388 | 2484701 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_mymodel3s_mymodel_id | relation | 16388 | 302488 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel3_address_id | relation | 16388 | 302516 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel3_mymodel2_id | relation | 16388 | 333704 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel | relation | 16388 | 19293 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel3_name_index | relation | 16388 | 2700014 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel_mymodel5_id | relation | 16388 | 302490 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_mymodel2_id | relation | 16388 | 333698 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodel5_id_6dce956e264c19df_uniq | relation | 16388 | 2576203 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_denorm_locs_id | relation | 16388 | 2725185 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_title_index | relation | 16388 | 2700114 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel3_name_129459df841fd9de_uniq | relation | 16388 | 333668 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel3_location_id | relation | 16388 | 302517 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_end_date | relation | 16388 | 302483 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_pkey | relation | 16388 | 302308 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel3_name | relation | 16388 | 333705 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
| transactionid | | | | | | 14771961 | | | | 5/11758 | 2744 | ExclusiveLock | t | f
core_location_loc_id | relation | 16388 | 302470 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel3_pkey | relation | 16388 | 302361 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel_mymodel3s_mymodel_id_5dcd946e263a391f_uniq | relation | 16388 | 302310 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_start_date | relation | 16388 | 302487 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodel4_id | relation | 16388 | 302491 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_mymodel3s_pkey | relation | 16388 | 302312 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
(91 rows)
这里是SELECT relation::regclass,*从pg_锁中获得代码>:
relation | locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath
----------+---------------+----------+----------+------+-------+------------+---------------+---------+-------+----------+--------------------+------+-----------+---------+----------
| transactionid | | | | | | 14771737 | | | | 5/11758 | 2744 | ShareLock | f | f
(1 row)
relation | locktype | database | relation | page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | pid | mode | granted | fastpath
------------------------------------------------------------+---------------+----------+----------+-------+-------+------------+---------------+---------+-------+----------+--------------------+------+------------------+---------+----------
pg_locks | relation | 16388 | 11090 | | | | | | | | 3/39008 | 3658 | AccessShareLock | t | t
| virtualxid | | | | | 3/39008 | | | | | 3/39008 | 3658 | ExclusiveLock | t | t
core_mymodel_mymodel3s | relation | 16388 | 19314 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel3 | relation | 16388 | 19386 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_location | relation | 16388 | 19243 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_denorm_locs_id | relation | 16388 | 2725185 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_title_index | relation | 16388 | 2700114 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_detail_html_index | relation | 16388 | 2700113 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
title | relation | 16388 | 2645243 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_mymodel5_id_6dce956e264c19df_uniq | relation | 16388 | 2576203 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_mymodels_query | relation | 16388 | 2484701 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_mymodel2_id | relation | 16388 | 333698 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_mymodel4_id | relation | 16388 | 302491 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_mymodel5_id | relation | 16388 | 302490 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_start_date | relation | 16388 | 302487 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_end_date | relation | 16388 | 302483 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel_pkey | relation | 16388 | 302308 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
core_mymodel | relation | 16388 | 19293 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | t
| virtualxid | | | | | 4/44 | | | | | 4/44 | 2241 | ExclusiveLock | t | t
core_mymodel_mymodel3s | relation | 16388 | 19314 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel3 | relation | 16388 | 19386 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_location | relation | 16388 | 19243 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_denorm_locs_id | relation | 16388 | 2725185 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_title_index | relation | 16388 | 2700114 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_detail_html_index | relation | 16388 | 2700113 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
title | relation | 16388 | 2645243 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_mymodel5_id_6dce956e264c19df_uniq | relation | 16388 | 2576203 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_mymodels_query | relation | 16388 | 2484701 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_mymodel2_id | relation | 16388 | 333698 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_mymodel4_id | relation | 16388 | 302491 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_mymodel5_id | relation | 16388 | 302490 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_start_date | relation | 16388 | 302487 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_end_date | relation | 16388 | 302483 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel_pkey | relation | 16388 | 302308 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
core_mymodel | relation | 16388 | 19293 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | t
| virtualxid | | | | | 5/11758 | | | | | 5/11758 | 2744 | ExclusiveLock | t | t
core_mymodel_mymodel4_id | relation | 16388 | 302491 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodel3s_pkey | relation | 16388 | 302312 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel_mymodel3s_mymodel_id_5dcd946e263a391f_uniq | relation | 16388 | 302310 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel_start_date | relation | 16388 | 302487 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
| transactionid | | | | | | 14771737 | | | | 4/44 | 2241 | ExclusiveLock | t | f
core_location_loc_id | relation | 16388 | 302470 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel3_pkey | relation | 16388 | 302361 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_end_date | relation | 16388 | 302483 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_pkey | relation | 16388 | 302308 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel3_name | relation | 16388 | 333705 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_denorm_locs_id | relation | 16388 | 2725185 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_title_index | relation | 16388 | 2700114 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel3_name_129459df841fd9de_uniq | relation | 16388 | 333668 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel | tuple | 16388 | 19293 | 93104 | 3 | | | | | | 5/11758 | 2744 | ExclusiveLock | t | f
core_mymodel3_location_id | relation | 16388 | 302517 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel3_name_index | relation | 16388 | 2700014 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_mymodel5_id | relation | 16388 | 302490 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodel2_id | relation | 16388 | 333698 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_mymodel5_id_6dce956e264c19df_uniq | relation | 16388 | 2576203 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodel3s_mymodel_id | relation | 16388 | 302488 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel3_address_id | relation | 16388 | 302516 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel3_mymodel2_id | relation | 16388 | 333704 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel | relation | 16388 | 19293 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_location_pkey | relation | 16388 | 302276 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_mymodel3s_mymodel3_id | relation | 16388 | 302489 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
title | relation | 16388 | 2645243 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_detail_html_index | relation | 16388 | 2700113 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodels_query | relation | 16388 | 2484701 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_location_pkey | relation | 16388 | 302276 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel_mymodel3s_mymodel3_id | relation | 16388 | 302489 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
title | relation | 16388 | 2645243 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_detail_html_index | relation | 16388 | 2700113 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_mymodels_query | relation | 16388 | 2484701 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_mymodel3s_mymodel_id | relation | 16388 | 302488 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel3_address_id | relation | 16388 | 302516 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel3_mymodel2_id | relation | 16388 | 333704 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel | relation | 16388 | 19293 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel3_name_index | relation | 16388 | 2700014 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel_mymodel5_id | relation | 16388 | 302490 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_mymodel2_id | relation | 16388 | 333698 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodel5_id_6dce956e264c19df_uniq | relation | 16388 | 2576203 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_denorm_locs_id | relation | 16388 | 2725185 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_title_index | relation | 16388 | 2700114 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel3_name_129459df841fd9de_uniq | relation | 16388 | 333668 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel3_location_id | relation | 16388 | 302517 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_end_date | relation | 16388 | 302483 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_pkey | relation | 16388 | 302308 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel3_name | relation | 16388 | 333705 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
| transactionid | | | | | | 14771961 | | | | 5/11758 | 2744 | ExclusiveLock | t | f
core_location_loc_id | relation | 16388 | 302470 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel3_pkey | relation | 16388 | 302361 | | | | | | | | 5/11758 | 2744 | AccessShareLock | t | f
core_mymodel_mymodel3s_mymodel_id_5dcd946e263a391f_uniq | relation | 16388 | 302310 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
core_mymodel_start_date | relation | 16388 | 302487 | | | | | | | | 5/11758 | 2744 | RowExclusiveLock | t | f
core_mymodel_mymodel4_id | relation | 16388 | 302491 | | | | | | | | 4/44 | 2241 | RowExclusiveLock | t | f
core_mymodel_mymodel3s_pkey | relation | 16388 | 302312 | | | | | | | | 4/44 | 2241 | AccessShareLock | t | f
(91 rows)
据我所知,尝试访问id=123行的唯一客户机就是尝试更新它的同一客户机。我也不知道为什么我从数据库中获取的只是一个主键列表,而这个查询已经完成了,它却要为所有这些列请求锁。另外,当迁移过程挂起时,我不得不终止迁移过程时,许多已授予的锁仍然存在。我已尝试重新启动数据库,但迁移仍然失败
另外,选择pg_terminate_backend(pid)
没有停止任何后端,只是重新启动数据库似乎可以清除它们。我重新启动了数据库,删除了新字段,读取了它,然后运行了VACUUM Analysis VERBOSE
。更新查询现在似乎正在完成,尽管其中一些查询会随机比其他查询长几个数量级。最后一点很有趣-这表明他们在做一些不检查中断的工作,比如库。如果你热衷于连接gdb
,并获得其中一个的回溯。谢谢,我会试一试。不幸的是,我不认为这是可以做到的,因为我使用的是RDS。我发现这与Craig所说的有关: