当查询频率过快时 报runtime: name offset base pointer out of range的错误
zhoujinlong opened this issue · comments
eam_swap_rt | {"@timestamp":"2023-02-16T22:30:37.674+08:00","caller":"logic/common.go:675","content":"查询语句:select state_rule_models_id
,state_rule_partner_id
,state_rule_equipment_id
,classify_id
,cate_id
,level_id
,param_id
,param
,pid
,rule_standard_type
,point
,point_name
,point_unit_id
,point_unit_name
,product_id
,state_rule_device_id
,equipment_id
,device_id
,classify_type_id
,classify_type_default_classify_id
,company_id
,company_index_id
,state_rule_id
from state_rule.state_rule where product_id
='7c1ff8a329e59528' and device_id
='3c98d6d84301ec9f' order by ts desc","level":"info"}
eam_swap_rt | runtime: nameOff 0x1 base 0xc000d1d580 not in ranges:
eam_swap_rt | types 0xbf7020 etypes 0xf03710
eam_swap_rt | fatal error: runtime: name offset base pointer out of range
eam_swap_rt |
eam_swap_rt | goroutine 17 [running, locked to thread]:
eam_swap_rt | runtime.throw({0xde02cc, 0x0})
eam_swap_rt | /usr/local/go/src/runtime/panic.go:1198 +0x71 fp=0xc000066ab8 sp=0xc000066a88 pc=0x43b3f1
eam_swap_rt | runtime.resolveNameOff(0x7f123719ffff, 0x1)
eam_swap_rt | /usr/local/go/src/runtime/type.go:210 +0x1d6 fp=0xc000066b10 sp=0xc000066ab8 pc=0x463c76
eam_swap_rt | runtime.(_type).nameOff(...)
eam_swap_rt | /usr/local/go/src/runtime/type.go:216
eam_swap_rt | runtime.(_type).string(0xc000d1d580)
eam_swap_rt | /usr/local/go/src/runtime/type.go:51 +0x25 fp=0xc000066b30 sp=0xc000066b10 pc=0x4638e5
eam_swap_rt | runtime.(*TypeAssertionError).Error(0xc000fba690)
eam_swap_rt | /usr/local/go/src/runtime/error.go:39 +0x9e fp=0xc000066c38 sp=0xc000066b30 pc=0x40c2fe
eam_swap_rt | runtime.preprintpanics(0xc000c1d310)
eam_swap_rt | /usr/local/go/src/runtime/panic.go:701 +0x7f fp=0xc000066c98 sp=0xc000066c38 pc=0x439c7f
eam_swap_rt | panic({0xcb7940, 0xc000fba690})
eam_swap_rt | /usr/local/go/src/runtime/panic.go:1145 +0x39a fp=0xc000066d58 sp=0xc000066c98 pc=0x43af7a
eam_swap_rt | runtime.getitab(0xcc40c0, 0xc000d1d580, 0xe0)
eam_swap_rt | /usr/local/go/src/runtime/iface.go:44 +0x285 fp=0xc000066da0 sp=0xc000066d58 pc=0x40e6e5
eam_swap_rt | runtime.assertE2I(0x14f8540, 0xc699c0)
eam_swap_rt | /usr/local/go/src/runtime/iface.go:482 +0x25 fp=0xc000066dc8 sp=0xc000066da0 pc=0x40f725
eam_swap_rt | github.com/taosdata/driver-go/v2/wrapper.QueryCallback(0xc000036060, 0x0, 0x0)
eam_swap_rt | /go/pkg/mod/github.com/taosdata/driver-go/v2@v2.0.4/wrapper/asynccb.go:24 +0x58 fp=0xc000066e08 sp=0xc000066dc8 pc=0xb736f8
eam_swap_rt | _cgoexp_e608cae81cef_QueryCallback(0x7f1221bf3c40)
eam_swap_rt | _cgo_gotypes.go:796 +0x26 fp=0xc000066e30 sp=0xc000066e08 pc=0xb77146
eam_swap_rt | runtime.cgocallbackg1(0xb77120, 0xc000066fe0, 0x0)
eam_swap_rt | /usr/local/go/src/runtime/cgocall.go:306 +0x29a fp=0xc000066f00 sp=0xc000066e30 pc=0x40801a
eam_swap_rt | runtime.cgocallbackg(0x0, 0x0, 0x0)
eam_swap_rt | /usr/local/go/src/runtime/cgocall.go:232 +0x109 fp=0xc000066f90 sp=0xc000066f00 pc=0x407ce9
eam_swap_rt | runtime.cgocallbackg(0xb77120, 0x7f1221bf3c40, 0x0)
eam_swap_rt | :1 +0x2f fp=0xc000066fb8 sp=0xc000066f90 pc=0x47150f
eam_swap_rt | runtime.cgocallback(0x0, 0x0, 0x0)
eam_swap_rt | /usr/local/go/src/runtime/asm_amd64.s:915 +0xb4 fp=0xc000066fe0 sp=0xc000066fb8 pc=0x46f0f4
eam_swap_rt | runtime.goexit()
eam_swap_rt | /usr/local/go/src/runtime/asm_amd64.s:1581 +0x1 fp=0xc000066fe8 sp=0xc000066fe0 pc=0x46f301
tdengine用的是2.4.0.16,driver-go版本用的是v2.0.4
示例代码:
// 获取状态规则列表
func (t *Tdengine) GetStateRuleList(where map[string]string) ([]*StateRuleTdObj, error) {
whereStr := t.setwhere(where)
fields := []string{
"state_rule_models_id", "state_rule_partner_id", "state_rule_equipment_id", "classify_id", "cate_id", "level_id", "param_id", "param", "pid", "rule_standard_type", "point", "point_name", "point_unit_id", "point_unit_name", "product_id", "state_rule_device_id", "equipment_id", "device_id", "classify_type_id", "classify_type_default_classify_id", "company_id", "company_index_id", "state_rule_id",
}
filedSet := t.setfield(fields)
stable := enum.TDENGINE_STATUS_RULE_STABLE_NAME
rowsData := make([]StateRuleTdObj, 0)
query := fmt.Sprintf("select %s from %s %s order by ts desc", filedSet, t.DbName+"."+stable, whereStr)
logx.Info("查询语句:", query)
conn, err := t.ConnNew()
if err != nil {
return nil, err
}
defer conn.Close()
// conn := SRConn
// count
// countQuery := fmt.Sprintf("select count() as count
from %s %s", t.DbName+"."+stable, whereStr)
// logx.Info("countQuery:", countQuery)
// rowsCount := conn.QueryRow(countQuery)
// logx.Errorf("%v",rowsCount.Err())
// var count int64
// if err := rowsCount.Scan(&count); err != nil {
// logx.Error("count赋值err:", err)
// return nil, err
// }
// logx.Info("记录条数:", count)
// if count == 0 {
// return rowsData, nil
// }
// end count
rows, err := conn.Query(query)
if err != nil {
return nil, err
}
for rows.Next() {
var r StateRuleTdObj
if err := rows.Scan(&r.StateRuleModelsId, &r.StateRulePartnerId, &r.StateRuleEquipmentId, &r.ClassifyId, &r.CateId, &r.LevelId, &r.ParamId, &r.Param, &r.Pid, &r.RuleStandardType, &r.Point, &r.PointName, &r.PointUnitId, &r.PointUnitName, &r.ProductId, &r.StateRuleDeviceId, &r.EquipmentId, &r.DeviceId, &r.ClassifyTypeId, &r.ClassifyTypeDefaultClassifyId, &r.CompanyId, &r.CompanyIndexId, &r.StateRuleId); err != nil {
logx.Error("机理模型查询err:", err)
return nil, err
}
rowsData = append(rowsData, &r)
}
return rowsData, nil
}
func (t *Tdengine) GetModelsTheoryList(equipmentId int64) ([]*ModuleTheoryTdObj, error) {
fields := []string{
"equipment_id", "name", "device_id", "product_id", "model_value", "gid", "threshold_type", "threshold", "models_param_id", "standard_type", "standard", "point", "param_type", "point_name", "point_unit_name", "theory_id",
}
filedSet := t.setfield(fields)
stable := enum.TDENGINE_MODULE_THEORY_STABLE_NAME
rowsData := make([]*ModuleTheoryTdObj, 0)
query := fmt.Sprintf("select %s from %s where equipment_id=%d order by ts desc", filedSet, t.DbName+"."+stable, equipmentId)
logx.Info("查询语句:", query)
conn, err := t.ConnNew()
if err != nil {
return nil, err
}
defer conn.Close()
rows, err := conn.Query(query)
if err != nil {
return nil, err
}
for rows.Next() {
var r ModuleTheoryTdObj
if err := rows.Scan(&r.EquipmentId, &r.Name, &r.DeviceId, &r.ProductId, &r.ModelValue, &r.Gid, &r.ThresholdType, &r.Threshold, &r.ModelsParamId, &r.StandardType, &r.Standard, &r.Point, &r.ParamType, &r.PointName, &r.PointUnitName, &r.TheoryId); err != nil {
logx.Error("机理模型查询err:", err)
return nil, err
}
rowsData = append(rowsData, &r)
}
return rowsData, nil
}
请问每次查询会返回多少条数据
每次返回的数据量不多,有的多有的少,20-30条吧,当没有查询到记录也会出现这种情况
您可以升级 TDengnie 到3.0.2.5,driver-go 到 3.1.0 再试一下