cody_liu
cody_liu
  • 发布:2021-12-08 23:00
  • 更新:2021-12-09 17:17
  • 阅读:405

unicloud执行sql有一定概率失败,麻烦棒忙排查

分类:uniCloud

云函数有一定概率失败,麻烦棒忙排查:
失败的请求:请求入参: {
"args": {
"action": "getChatlist",
"params": {
"to_uid": "61adf09481337a00013fc3ee"
},
"clientInfo": {
"PLATFORM": "mp-weixin",
"OS": "devtools",
"APPID": "UNIF150529",
"LOCALE": "zh-Hans",
"DEVICEID": "16389380767333621159",
"CLIENT_SDK_VERSION": "1.0.14"
},
"uniIdToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI2MWFkZjA5NDgxMzM3YTAwMDEzZmMzZWUiLCJyb2xlIjpbIlVTRVIiXSwicGVybWlzc2lvbiI6WyJOT1RJQ0VfQUREIiwiTk9USUNFX0VESVQiLCJOT1RJQ0VfREVMIl0sImlhdCI6MTYzODk3NTM5MSwiZXhwIjoxNjM4OTgyNTkxfQ.Z3JzNCjens1psZqtrjblo5vwfU6BMFKXIeokV4tb_7o"
},
"requestId": "ac1406941638975396456111358"
}
[message/ac1406941638975396456111358/1ms/DEBUG] event : { action: 'getChatlist',
params: { to_uid: '61adf09481337a00013fc3ee' },
uniIdToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI2MWFkZjA5NDgxMzM3YTAwMDEzZmMzZWUiLCJyb2xlIjpbIlVTRVIiXSwicGVybWlzc2lvbiI6WyJOT1RJQ0VfQUREIiwiTk9USUNFX0VESVQiLCJOT1RJQ0VfREVMIl0sImlhdCI6MTYzODk3NTM5MSwiZXhwIjoxNjM4OTgyNTkxfQ.Z3JzNCjens1psZqtrjblo5vwfU6BMFKXIeokV4tb_7o' }

成功的:请求入参: {
"args": {
"action": "getChatlist",
"params": {
"to_uid": "61adf09481337a00013fc3ee"
},
"clientInfo": {
"PLATFORM": "mp-weixin",
"OS": "devtools",
"APPID": "UNIF150529",
"LOCALE": "zh-Hans",
"DEVICEID": "16389380767333621159",
"CLIENT_SDK_VERSION": "1.0.14"
},
"uniIdToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI2MWFkZjA5NDgxMzM3YTAwMDEzZmMzZWUiLCJyb2xlIjpbIlVTRVIiXSwicGVybWlzc2lvbiI6WyJOT1RJQ0VfQUREIiwiTk9USUNFX0VESVQiLCJOT1RJQ0VfREVMIl0sImlhdCI6MTYzODk3MzY3MCwiZXhwIjoxNjM4OTgwODcwfQ.TgCTmBBaNez0NUCHT8Y2brnqwpMZKcTvkrdfVt0y_tg"
},
"requestId": "ac141d161638975305230187286"
}
[message/ac141d161638975305230187286/1ms/DEBUG] event : { action: 'getChatlist',
params: { to_uid: '61adf09481337a00013fc3ee' },
uniIdToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOiI2MWFkZjA5NDgxMzM3YTAwMDEzZmMzZWUiLCJyb2xlIjpbIlVTRVIiXSwicGVybWlzc2lvbiI6WyJOT1RJQ0VfQUREIiwiTk9USUNFX0VESVQiLCJOT1RJQ0VfREVMIl0sImlhdCI6MTYzODk3MzY3MCwiZXhwIjoxNjM4OTgwODcwfQ.TgCTmBBaNez0NUCHT8Y2brnqwpMZKcTvkrdfVt0y_tg' }
请求响应状态: success

2021-12-08 23:00 负责人:无 分享
已邀请:

最佳回复

DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

此问题由复用aggregate实例引起。文档已补充说明

以下两种写法均为错误示例:

const db = uniCloud.database()  
const collection = db.collection('test')  
const aggregate = collection.aggregate() // 云函数实例复用时,此聚合实例也会复用,导致Bug  
exports.main = async function(){  
  const res = await aggregate.match({a:1}).end()  
  return {res}  
}
const db = uniCloud.database()  
const collection = db.collection('test')  
exports.main = async function(){  
  const aggregate = collection.aggregate() // 此聚合实例分别在两个请求内使用,导致Bug  
  const res1 = await aggregate.match({a:1}).end()  
  const res2 = await aggregate.match({a:2}).end()  
  return {res1, res2}  
}
cody_liu

cody_liu (作者)

这是执行的sql

DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

失败的时候前端收到的错误信息是什么?to_uid有没有添加索引,集合记录数量大不大

cody_liu

cody_liu (作者)

这是表结构

cody_liu

cody_liu (作者)

这笔又失败了,刚刚请求的

cody_liu

cody_liu (作者)

这是云函数日志

该问题目前已经被锁定, 无法添加新回复