-
Notifications
You must be signed in to change notification settings - Fork 204
Closed
Labels
bugSomething isn't workingSomething isn't workingnot_compatible需要升级方案需要升级方案publish-pre3verifiedthe issue all pr is verifiedthe issue all pr is verified
Milestone
Description
版本信息(Version)
sqle@latest
修复版本
3.2410.0-pre3
3.2404.1(临时修复panic问题)
问题描述(Describe)
使用特定SQL生成指纹时,由于生成的指纹长度大于原有SQL,FingerPrint算法访问的数组越界,产生panic
类似问题:percona/go-mysql#30
截图或日志(Log)
github.com/percona/go-mysql/query.Fingerprint({0xc001fba800?, 0xc0006e5ac8?})
/universe/vendor/github.com/percona/go-mysql/query/query.go:779 +0x3c5f
github.com/actiontech/sqle/sqle/server/auditplan.mergeSQLsFromHuaweiCloud({0xc0026a8000, 0x7d0, 0xc00149f7d0?})
/universe/sqle/server/auditplan/huawei_task.go:263 +0x14c
github.com/actiontech/sqle/sqle/server/auditplan.(*huaweiRdsMySQLTask).collectorDo(0xc0012708e8)
/universe/sqle/server/auditplan/huawei_task.go:229 +0xc9f
github.com/actiontech/sqle/sqle/server/auditplan.(*sqlCollector).loop(0xc00160b480, 0xc00160d8c0, 0x34630b8a000)
/universe/sqle/server/auditplan/task.go:237 +0x47
github.com/actiontech/sqle/sqle/server/auditplan.(*sqlCollector).Start.func1()
/universe/sqle/server/auditplan/task.go:209 +0x65
created by github.com/actiontech/sqle/sqle/server/auditplan.(*sqlCollector).Start
/universe/sqle/server/auditplan/task.go:206 +0x8d
panic: runtime error: index out of range [961] with length 961
临时修复方案
如何复现(To Reproduce)
生成的指纹长度大于原有SQL
例:
func TestName(t *testing.T) {
fp := query.Fingerprint(`insert into tb values(1)`)
fmt.Println("11", fp)
}
// 这条SQL虽然是错误的,但也可以触发panic :SELECT*FROM (SELECT * FROM tb values(1));
问题原因
github.com/percona/go-mysql/query的指纹生成函数缺陷
解决方案
使用github.com/actiontech/sqle/sqle/driver/mysql/util中的指纹函数替换github.com/percona/go-mysql/query
涉及替换的地方:
- sqle/pkg/driver/impl.go 中 DriverImpl.Parse 方法中
- sqle/cmd/scannerd/scanners/tidb_audit_log/audit_log_ee.go
变更影响面
受影响的模块或功能
- 依赖变更后的sqle/pkg/driver/impl.go实现的的插件 会使用新的指纹算法
- scannerd 执行tidb_audit_log时 会使用新的指纹算法,需要升级scannerd
外部引用的潜在问题或风险
版本兼容性
测试建议
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingnot_compatible需要升级方案需要升级方案publish-pre3verifiedthe issue all pr is verifiedthe issue all pr is verified