GAE的datastore在index上的bug

仿照google的guestbook这个sample写了一个,upload到appengine host上后,访问页面却出错了:

# 221.221.203.253 - - [21/06/2008:10:13:01 -0700] "GET / HTTP/1.1" 500 1908 "http://appengine.google.com/deployment?app_id=vanvc" - #
E 06-21 10:13AM 01.565

Traceback (most recent call last):
  File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 499, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/vanvc/0.6/vanvc.py", line 44, in get
    self.response.out.write(template.render(path, template_values))
  File "/base/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 81, in render
    return t.render(Context(template_dict))
  File "/base/python_lib/versions/1/google/appengine/ext/webapp/template.py", line 121, in wrap_render
    return orig_render(context)
  File "/base/python_lib/versions/1/django/template/__init__.py", line 168, in render
    return self.nodelist.render(context)
  File "/base/python_lib/versions/1/django/template/__init__.py", line 705, in render
    bits.append(self.render_node(node, context))
  File "/base/python_lib/versions/1/django/template/__init__.py", line 718, in render_node
    return(node.render(context))
  File "/base/python_lib/versions/1/django/template/defaulttags.py", line 99, in render
    values = list(values)
  File "/base/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1247, in __iter__
    return self.run()
  File "/base/python_lib/versions/1/google/appengine/ext/db/__init__.py", line 1558, in run
    query_run = self._proto_query.Run(*self._args, **self._kwds)
  File "/base/python_lib/versions/1/google/appengine/ext/gql/__init__.py", line 441, in Run
    res = bind_results.Get(self.__limit, offset)
  File "/base/python_lib/versions/1/google/appengine/api/datastore.py", line 928, in Get
    return self._Run(limit, offset)._Next(limit)
  File "/base/python_lib/versions/1/google/appengine/api/datastore.py", line 877, in _Run
    str(exc) + '\nThis query needs this index:\n' + yaml)
NeedIndexError: no matching index found
This query needs this index:
- kind: Greeting
  properties:
  - name: date
    direction: desc

从错误log中可以看出是index的问题:google app engine使用叫做datastore的东西来存储数据,这个东东是基于赫赫有名的BigTable的.我写了一个查询:

class MainPage(webapp.RequestHandler):
  def get(self):
    greetings=db.GqlQuery("SELECT * "
                          "FROM Greeting"
                          "ORDER BY date DESC LIMIT 15")
   ..........
   ..........

这个Entity的样子是这样:

class Greeting(db.Model):
  author=db.UserProperty()
  content=db.StringProperty()
  date=db.DateTimeProperty(auto_now_add=True)

查询很简单,就是要按照date字段倒排序,在使用dev_appserver.py来本机调试的时候,当执行到这个查询,会自动生成一个index.yaml文件,这个文件里存储了对哪些表的哪些字段添加什么样的index的配置.但是upload到服务器上后就看到了文章一开始的错误报告.

登陆到管理员后台,查看index一项,报告说status是building,而不是期待的serving.如果这个状态值为building,那么执行查询就会报错的.但是等了2小时后,还是building.

于是把查询去掉了oderby,这下可以正常运行了,感觉不错.但是一到administration console下看到那个讨厌的building的index就想干掉它:

1

我修改了index.yaml然后再update,那么当前这个version下面就不需要任何index了.然后用vacuum_indexes来删除掉不用的索引. GAE知道我不再使用它了,问我是否删除,我选择Y,但是告诉我的却是500. --force再试,强迫删除,错误依旧 :(

愁死...

[Update / Jun 22]
今天中午起床后的第一件事就是检查一下adminstrator console,这个index终于是serving的状态了...

posted @ 2008-06-22 02:38  new 维生素C.net()  阅读(1088)  评论(3编辑  收藏  举报