gpt4 book ai didi

google-app-engine - Google App Engine 超时 : The datastore operation timed out, 或数据暂时不可用

转载 作者:太空宇宙 更新时间:2023-11-03 15:19:17 25 4
gpt4 key购买 nike

这是一个常见的异常,我每天都会在我的应用程序日志中获取,通常一天 5/6 次,访问量为 1K 次/天:

db error trying to store stats
Traceback (most recent call last):
File "/base/data/home/apps/stackprinter/1b.347728306076327132/app/utility/worker.py", line 36, in deferred_store_print_statistics
dbcounter.increment()
File "/base/data/home/apps/stackprinter/1b.347728306076327132/app/db/counter.py", line 28, in increment
db.run_in_transaction(txn)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", line 1981, in RunInTransaction
DEFAULT_TRANSACTION_RETRIES, function, *args, **kwargs)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", line 2067, in RunInTransactionCustomRetries
ok, result = _DoOneTry(new_connection, function, args, kwargs)
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py", line 2105, in _DoOneTry
if new_connection.commit():
File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1585, in commit
return rpc.get_result()
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/apiproxy_stub_map.py", line 530, in get_result
return self.__get_result_hook(self)
File "/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py", line 1613, in __commit_hook
raise _ToDatastoreError(err)
Timeout: The datastore operation timed out, or the data was temporarily unavailable.

引发上述异常的函数如下:

def store_printed_question(question_id, service, title):
def _store_TX():
entity = Question.get_by_key_name(key_names = '%s_%s' % \
(question_id, service ) )
if entity:
entity.counter = entity.counter + 1
entity.put()
else:
Question(key_name = '%s_%s' % (question_id, service ),\
question_id ,\
service,\
title,\
counter = 1).put()
db.run_in_transaction(_store_TX)

基本上,store_printed_question 函数会检查给定的问题之前是否已打印,在这种情况下会在单个事务中递增相关计数器。
此函数由 WebHandler 添加到 deferred使用预定义 的工作人员 default 队列,如您所知,其吞吐量为每秒五次任务调用。

在具有六个属性(两个索引)的实体上,我认为使用 transactions由延迟任务速率限制调节可以让我避免数据存储超时,但是查看日志,这个错误仍然每天都出现。

我存储的这个计数器不是那么重要,所以我不担心这些超时;无论如何,我很好奇为什么 Google App Engine 即使以每秒 5 个任务的低速率也无法正确处理此任务,如果降低速率可能是一个可能的解决方案。
sharded counter在每个问题上避免超时对我来说都太过分了。

编辑:
我已将默认队列的速率限制设置为每秒 1 个任务;我仍然遇到同样的错误。

最佳答案

查询只能存在 30 秒。请参阅我对 this question 的回答一些使用游标分解查询的示例代码。

关于google-app-engine - Google App Engine 超时 : The datastore operation timed out, 或数据暂时不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4745538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com