douyanjing8287 2013-12-27 18:25
浏览 63

检索不存在的对象时,“数据存储:内部错误:服务器返回的实体数错误”

With the go API for Google App Engine I try to retrieve a non-existent object:

func entityKey(c appengine.Context, name string) *datastore.Key {
    collectionKey := datastore.NewKey(c, "EntityCollection", "default_entitycollection", 0, nil)
    return datastore.NewKey(c, "Entity", name, 0, collectionKey)
}

//.....

var record EntityRecord // Some random type

key := entityKey(context, "This key does not exist")

err := datastore.Get(context, key, &record)

It returns the error:

datastore: internal error: server returned the wrong number of entities

Whereas I expect the much more obvious ErrNoSuchEntity. What gives?

This is on the local development server.

  • 写回答

1条回答 默认 最新

  • doyz51819 2013-12-28 02:57
    关注

    The error is from here. Given the internal error bit this sounds like a bug to me. Reading the code it seems like it should return a slice with one GetResponse_Entity with a nil Entity field, but it's either returning too many GetResponse_Entitys or none.

    You could tinker with the source code in:

    go_appengine\goroot\src\pkg\appengine\datastore\datastore.go
    

    Add some fmt.Printlns to this part:

    req := &pb.GetRequest{
        Key: multiKeyToProto(c.FullyQualifiedAppID(), key),
    }
    res := &pb.GetResponse{}
    if err := c.Call("datastore_v3", "Get", req, res, nil); err != nil {
        return err
    }
    

    Or perhaps try debugging with GDB. (though I'm not sure how you debug an app engine app)

    You could also try clearing your local data store with:

    dev_appserver.py --clear_datastore=yes myapp
    

    But that's just a shot in the dark.

    You might have better luck asking on the mailing list.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度