使用python云引擎,之前正常的系统,这两天保存的时候会抛出下面的错误

Traceback (most recent call last):
ERROR 2016-01-21 12:44:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/routes/login/game9g_Login.py", line 68, in get
ERROR 2016-01-21 12:44:37     data = player.cover_data_for_html()
ERROR 2016-01-21 12:44:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/models/player.py", line 359, in cover_data_for_html
ERROR 2016-01-21 12:44:37     "rank": Friend_Query.get_player_rank_in_friends(self),
ERROR 2016-01-21 12:44:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/dao/friendQuery.py", line 107, in get_player_rank_in_friends
ERROR 2016-01-21 12:44:37     count = query.count()
ERROR 2016-01-21 12:44:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/lib/python2.7/site-packages/leancloud/query.py", line 204, in count
ERROR 2016-01-21 12:44:37     response = client.get('/classes/{0}'.format(self._query_class._class_name), params)
ERROR 2016-01-21 12:44:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/lib/python2.7/site-packages/leancloud/client.py", line 79, in new_func
ERROR 2016-01-21 12:44:37     return func(headers=headers, *args, **kwargs)
ERROR 2016-01-21 12:44:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/lib/python2.7/site-packages/leancloud/client.py", line 140, in new_func
ERROR 2016-01-21 12:44:37     raise leancloud.LeanCloudError(content.get('code', 1), content.get('error', 'Unknown Error'))
ERROR 2016-01-21 12:44:37 LeanCloudError: [303] Fail to execute operation on storage. Command failed with error 2: 'failed on : SHARD07' on server localhost:27020. The full response is { "shards" : { }, "cause" : { "errmsg" : "exception: $in needs an array", "code" : 2, "ok" : 0.0, "$gleStats" : { "lastOpTime" : { "$timestamp" : { "t" : 1453349846, "i" : 13 } }, "electionId" : { "$oid" : "567c96529accde5e197f5908" } } }, "code" : 2, "ok" : 0.0, "errmsg" : "failed on : SHARD07" }

Traceback (most recent call last):
ERROR 2016-01-21 14:16:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/routes/logic.py", line 70, in post
ERROR 2016-01-21 14:16:37     self.repack = self.msg_dispatch(packet)
ERROR 2016-01-21 14:16:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/routes/logic.py", line 101, in msg_dispatch
ERROR 2016-01-21 14:16:37     repacket = handler.packetProcess(packet)
ERROR 2016-01-21 14:16:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/routes/gameLogic/basicHandler.py", line 20, in packetProcess
ERROR 2016-01-21 14:16:37     return dealFun(packet)
ERROR 2016-01-21 14:16:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/routes/gameLogic/buildingHandler.py", line 217, in msg2003
ERROR 2016-01-21 14:16:37     self.player.player_info.on_save()
ERROR 2016-01-21 14:16:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/models/player_info.py", line 269, in on_save
ERROR 2016-01-21 14:16:37     self.save()
ERROR 2016-01-21 14:16:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/lib/python2.7/site-packages/leancloud/object_.py", line 163, in save
ERROR 2016-01-21 14:16:37     response = client.put('/classes/{0}/{1}'.format(self._class_name, self.id), data)
ERROR 2016-01-21 14:16:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/lib/python2.7/site-packages/leancloud/client.py", line 79, in new_func
ERROR 2016-01-21 14:16:37     return func(headers=headers, *args, **kwargs)
ERROR 2016-01-21 14:16:37   File "/mnt/avos/data/uluru-cloud-code/repos/GwjdMuyTvl0y9Ggge1VhAhNz/lib/python2.7/site-packages/leancloud/client.py", line 140, in new_func
ERROR 2016-01-21 14:16:37     raise leancloud.LeanCloudError(content.get('code', 1), content.get('error', 'Unknown Error'))
ERROR 2016-01-21 14:16:37 LeanCloudError: [124] The request timed out on the server. Typically this indicates the request is too expensive.

貌似这是两个不同地方的异常。能不能把这两个引发异常的查询发一下?我怀疑是有某些 in array 的操作,随着数据量增大,array 变得太长导致请求失败了。

第一个count查询,这个可能是数据量过大,第二个就不知道什么鬼了

openids = cls.__get_friend_openids(player.openid)
openids.append(player.openid)
query = Query("Player_Info")
query.contained_in("openid", openids)
query.descending("total_property")
result = query.find()

第二个保存:

key = Redis_Prefix.Save_Limit + self.openid
cold_time = 60
if redis_cli.set(key, 1, ex=cold_time, nx=True):
   self.save()

第一个里面具体的报错有一条:

"errmsg" : "exception: $in needs an array"

我怀疑 openids 不是个 list,能不能排查一下?

第二个好像没有写出来具体的查询 / save 操作的代码。

第一个哦,原来如此,
第二个有啊self.save()就只是简单调用了save这个方法而已

self 上 set 过哪些数据?