【发布时间】:2011-12-20 17:17:13
【问题描述】:
按照以下说明: http://neogregious.blogspot.com/2011/04/migrating-app-to-high-replication.html
我已成功迁移到高复制数据存储,但现在出现以下异常:
datastore_errors.BadArgumentError('ancestor argument should match app ("%r" != "%r")' %
(ancestor.app(), app))
模型数据如下所示:
class base_business(polymodel.PolyModel):
created = db.DateTimeProperty(auto_now_add=True)
class business(base_business):
some_data = db.StringProperty()
etc..
class business_image(db.Model):
image = db.BlobProperty(default=None)
mimetype = db.StringProperty()
comment = db.StringProperty(required=False)
# the image is associated like so
image_item = business_image(parent = business_item, etc... )
image_item.put()
新应用名称尚未分配给祖先模型数据。目前数据已返回,但日志中正在填充此异常消息。
使用 logging.exception 的实际堆栈跟踪:
2011-11-03 16:45:40.211 ======= get_business_image 异常 [祖先参数应该匹配 app ("'oldappname'" != "'s~newappname'")] ======= 回溯(最近一次通话最后): 文件“/base/data/home/apps/s~newappname/3.354412961756003398/oldappname/entities/views.py”,第 82 行,在 get_business_image business_img = business_image.gql("祖先在哪里 :ref_business 和 is_primary = True", ref_business = db.Key(business_key)).get() 文件“/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/init.py”,第 2049 行,在 get 结果 = self.fetch(1, config=config) 文件“/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/init.py”,第 2102 行,在 fetch raw = raw_query.Get(limit, offset, config=config) 文件“/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py”,第 1668 行,在 Get config=config,limit=limit,offset=offset,prefetch_size=limit)) GetBatcher 中的文件“/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py”,第 1600 行 return self.GetQuery().run(_GetConnection(), query_options) GetQuery 中的文件“/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore.py”,第 1507 行 order=self.GetOrder()) 文件“/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py”,第 93 行,位于 positional_wrapper 中 返回包装(*args,**kwds) init 中的文件“/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_query.py”,第 1722 行 祖先=祖先) 文件“/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_rpc.py”,第 93 行,位于 positional_wrapper 中 返回包装(*args,**kwds) init 中的文件“/base/python_runtime/python_lib/versions/1/google/appengine/datastore/datastore_query.py”,第 1561 行 (ancestor.app(), 应用程序)) BadArgumentError: 祖先参数应该匹配 app ("'oldappname'" != "'s~newappname'")
有没有办法在模型数据上手动设置应用程序?我可以做这样的事情来解决这个问题吗?
if( ancestor.app() != app )
set_app('my_app')
put()
在我这样做或应用任何其他 HACK 之前,作为数据迁移的一部分,我应该做些什么?
【问题讨论】:
-
代码在哪里?完整的堆栈跟踪在哪里?
-
这是完整的错误信息吗?看起来它在您自己编写的函数中,并且您似乎正在抑制实际异常并仅记录该异常。您可以修改它以记录原始堆栈跟踪吗? (只需使用 logging.exception 而不是 logging.error)。
-
在上面的正文中添加了 logging.exception 和生成的异常详细信息。
-
我想我已经从堆栈跟踪中弄清楚了发生了什么,facebook 和 google 正在使用包含先前应用程序名称的先前图像密钥请求图像。这也可以解释为什么当我只是浏览网站时它没有出现在日志中。它只会在谷歌搜索(可能只是图片)或在 facebook 的预览中出现。
标签: google-app-engine google-cloud-datastore