【问题标题】:Migrating an App to High-Replication Datastore - now ancestor issues将应用程序迁移到高复制数据存储区 - 现在是祖先问题
【发布时间】: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


【解决方案1】:

发生此类错误的原因通常是您在某处使用完全限定键,这些键已作为字符串(而不是 ReferenceProperty)存储在数据存储区中,或存储在数据存储区之外,例如 URL。您应该能够通过从外部源重建任何密钥来解决此问题,这样您就可以忽略 App ID,如下所示:

my_key = db.Key.from_path(*db.Key(my_key).to_path())

【讨论】:

  • 太棒了。再次感谢您对开发人员的大力支持 :)
  • 有趣的解决方案。我自己没有遇到这个问题,但它帮助我了解 GAE 是如何工作的。感谢 Google 和 Nick J 在信息和教学方面的出色表现。非常积极的是,像谷歌这样大的公司可以提供像应用程序引擎这样好的产品,看看现在十亿美元的公司,不是十亿美元的公司提供最好的技术,谷歌是个例外:十亿- 提供最佳技术解决方案的美元公司,否则我们必须寻找较小的技术专业供应商。
猜你喜欢
  • 2011-09-08
  • 2012-02-08
  • 2014-09-06
  • 2011-03-19
  • 1970-01-01
  • 1970-01-01
  • 2014-05-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多