"释放解锁锁定"带有threadsafe =的Google App Engine python 2.7中的错误

时间:2012-05-15 19:15:32

标签: google-app-engine python-2.7 python-multithreading

我看到Google App Engine(gqueues)上我的应用程序的日志中偶尔会出现“释放解锁锁定”错误,并且无法找出原因(下面的完整堆栈跟踪)。有谁知道为什么会出现这个错误?

有趣的是,应用程序在python 2.7上,threadsafe = NO,所以看起来很奇怪根本就会有锁定或锁定错误。

背景故事:GQueues在python2.5上,在4月初我将它迁移到2.7并设置threadsafe = True。一切都工作正常一周。然后在4月9日早上,整个应用程序无法访问,吐出500个错误。它不断产生新的服务器实例,其延迟超过30秒。我注意到在我的日志中我看到错误“无法解锁未锁定的锁”。我没有在迁移过程中为我的代码添加任何锁定机制,所以我认为这是错误引用的app引擎锁定。无论如何,我将我的应用程序回滚到仍然在Python 2.5上的先前版本,一切都开始工作了。

4月晚些时候,AppEngine停机时间通知显示4月9日他们的问题导致了python 2.7应用程序出现问题。 https://groups.google.com/d/topic/google-appengine-downtime-notify/QL8TmRn6Ay4/discussion

我跟进了谷歌的Christina Ilvento,她认为现在回到Python 2.7并转为threadsafe = True应该没问题。我迁移回2.7但是还保留了线程安全= False,认为我会给它几个星期以确保一切都在2.7上运行良好然后再次打开线程(我认为这导致了问题)。一切都运行良好几周,但现在我看到这个“释放解锁锁定”错误,即使线程已禁用。有谁知道这里发生了什么?

克里斯蒂娜建议我在这里发布,App Engine团队会跟进。

release unlocked lock
Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/util.py", line 69, in check_login
    handler_method(self, *args)
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/main.py", line 297, in get
    self.generate('main.html', template_values)
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/baserequest.py", line 257, in generate
    self.response.out.write(template.render(path, values))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/webapp/template.py", line 92, in render
    return t.render(Context(template_dict))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/webapp/template.py", line 172, in wrap_render
    return orig_render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 173, in render
    return self._render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 794, in render
    bits.append(self.render_node(node, context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 807, in render_node
    return node.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/loader_tags.py", line 139, in render
    return self.template.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 173, in render
    return self._render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 794, in render
    bits.append(self.render_node(node, context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 807, in render_node
    return node.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/defaulttags.py", line 173, in render
    nodelist.append(node.render(context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/defaulttags.py", line 257, in render
    return self.nodelist_true.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 794, in render
    bits.append(self.render_node(node, context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 807, in render_node
    return node.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/loader_tags.py", line 139, in render
    return self.template.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 173, in render
    return self._render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 794, in render
    bits.append(self.render_node(node, context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 807, in render_node
    return node.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/loader_tags.py", line 139, in render
    return self.template.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 173, in render
    return self._render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 794, in render
    bits.append(self.render_node(node, context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 807, in render_node
    return node.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/defaulttags.py", line 173, in render
    nodelist.append(node.render(context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/loader_tags.py", line 139, in render
    return self.template.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 173, in render
    return self._render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 794, in render
    bits.append(self.render_node(node, context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 807, in render_node
    return node.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/loader_tags.py", line 139, in render
    return self.template.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 173, in render
    return self._render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 794, in render
    bits.append(self.render_node(node, context))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/__init__.py", line 807, in render_node
    return node.render(context)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/_internal/django/template/defaulttags.py", line 136, in render
    values = list(values)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/db/__init__.py", line 2312, in next
    return self.__model_class.from_entity(self.__iterator.next())
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2809, in next
    next_batch = self.__batcher.next()
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2671, in next
    return self.next_batch(self.AT_LEAST_ONE)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2708, in next_batch
    batch = self.__next_batch.get_result()
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 592, in get_result
    return self.__get_result_hook(self)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2450, in __query_result_hook
    self._batch_shared.conn.check_rpc_success(rpc)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_rpc.py",

更新: 以下是其中一个错误

的完整回溯
46.231.181.199 - sandra.martin [15/May/2012:03:28:44 -0700] "POST /items/ HTTP/1.1" 500 1306 "http://www.gqueues.com/main?q=ag1zfmdxdWV1ZXMtaHJkciILEgdBY2NvdW50GL-psgYMCxILU2hhcmVkUXVldWUYkU4M";;;; "Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0" "www.gqueues.com" ms=59858 cpu_ms=154948 api_cpu_ms=112433 cpm_usd=4.305925 instance=00c61b117cfbf1818fa4b0f779eacc7f4a9030
D 2012-05-15 05:27:45.121
postAction: reorder
E 2012-05-15 05:28:44.714
release unlocked lock
Traceback (most recent call last):
  File "/base/python27_runtime/python27_lib/versions/third_party/webapp2-2.3/webapp2.py", line 545, in dispatch
    return method(*args, **kwargs)
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/util.py", line 139, in check_login
    handler_method(self, *args)
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/items.py", line 371, in post
    self.reorder()
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/items.py", line 856, in reorder
    QueueSyncHandler.syncQueueViewers(clientId, itemQueue)
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/queuesync.py", line 197, in syncQueueViewers
    jsonObj['items']        = util.getJSONItems(queueItems, filter, queueViewer.type, accountObj)
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/util.py", line 1536, in getJSONItems
    jsonItem['subitems'] = getJSONItems(subItems, filter, type, accountObj, assignmentCompleted=assignmentCompleted, accountEmail=accountEmail)
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/util.py", line 1536, in getJSONItems
    jsonItem['subitems'] = getJSONItems(subItems, filter, type, accountObj, assignmentCompleted=assignmentCompleted, accountEmail=accountEmail)
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/util.py", line 1536, in getJSONItems
    jsonItem['subitems'] = getJSONItems(subItems, filter, type, accountObj, assignmentCompleted=assignmentCompleted, accountEmail=accountEmail)
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/controllers/util.py", line 1481, in getJSONItems
    if item.hasAssignments():
  File "/base/data/home/apps/s~gqueues-hrd/gq3-7-5.358902352474055782/models.py", line 1512, in hasAssignments
    itemAssignments = Assignment.all(keys_only=True).filter('item =', self).fetch(1)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/ext/db/__init__.py", line 2143, in fetch
    return list(self.run(limit=limit, offset=offset, **kwargs))
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2809, in next
    next_batch = self.__batcher.next()
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2671, in next
    return self.next_batch(self.AT_LEAST_ONE)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2708, in next_batch
    batch = self.__next_batch.get_result()
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 592, in get_result
    return self.__get_result_hook(self)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_query.py", line 2450, in __query_result_hook
    self._batch_shared.conn.check_rpc_success(rpc)
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1206, in check_rpc_success
    rpc.wait()
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 533, in wait
    self.__rpc.Wait()
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/api/apiproxy_rpc.py", line 119, in Wait
    rpc_completed = self._WaitImpl()
  File "/base/python27_runtime/python27_lib/versions/1/google/appengine/runtime/apiproxy.py", line 134, in _WaitImpl
    self.__done_event.wait()
  File "/base/python27_runtime/python27_dist/lib/python2.7/threading.py", line 407, in wait
    self.__cond.release()
error: release unlocked lock

1 个答案:

答案 0 :(得分:2)

感谢您的报告。我们(GAE python团队)知道这个bug。可能发生的事情是,您的处理程序可能已达到请求截止日期并遇到我们在https://developers.google.com/appengine/docs/python/runtime#The_Request_Timer处发出警告的问题。

你能为我检查几件事吗: 1.异常跟踪似乎不完整。如果可能,您可以发布完整的回溯。 2.您是否可以检查您的请求的请求时间(在日志中)并在此处发布。

编辑:最近发布了我链接到的页面上的警告。