【 使用环境 】生产环境
【 使用版本 】版本 5.7.25-OceanBase_CE-v4.3.3.0,集群部署
spring boot中jdbc使用 mysql-connector-j-8.0.33.jar驱动,
替换为官网推荐的mysql-connector-java-5.1.47.jar,两个驱动问题一样。
【问题描述】
(1)初始报错报错
Error querying database. Cause: java.sql.SQLException: Internal error
The error may exist in com/suninfo/userasset/mapper/asset/MonitorItcompMapper.xml
The error may involve com.suninfo.userasset.mapper.asset.MonitorItcompMapper.countItcompGroupbycitype-Inline
The error occurred while setting parameters
SQL: SELECT t1.citypeUuid AS name,count(t1.uuid) as value FROM t_monitor_itcomp t1 WHERE t1.citypeUuid is not null AND t1.status != 4 AND FIND_IN_SET(?, t1.module_codes) > 0 AND EXISTS (SELECT asset_uuid FROM (SELECT DISTINCT asset_uuid FROM t_asset_usedepart_rel WHERE usedepart_uuid IN ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ) AS ud WHERE ud.asset_uuid = t1.uuid) and t1.citypeUuid IN ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) GROUP BY t1.citypeUuid
Cause: java.sql.SQLException: Internal error
========================Exception End=============================
(2)去除t1.citypeUuid的查询条件后不报错,如下
SELECT t1.citypeUuid AS name,count(t1.uuid) as value FROM t_monitor_itcomp t1 WHERE t1.citypeUuid is not null AND t1.status != 4 AND FIND_IN_SET(?, t1.module_codes) > 0 AND EXISTS (SELECT asset_uuid FROM (SELECT DISTINCT asset_uuid FROM t_asset_usedepart_rel WHERE usedepart_uuid IN ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ) AS ud WHERE ud.asset_uuid = t1.uuid)
(3)根据业务修改sql后不报错
select
t1.citypeUuid as name,
count(t1.uuid) as value
from
t_monitor_itcomp t1
inner join t_cmdb_citype as t3 on
t1.citypeUuid = t3.uuid
inner join (
select
distinct asset_uuid
from
t_asset_usedepart_rel
where
usedepart_uuid in ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ) as t4 on
t1.uuid = t4.asset_uuid
where
t1.status != 4
and FIND_IN_SET(‘3’, t1.module_codes) > 0
and FIND_IN_SET(‘3’, t3.module_codes) > 0
group by
t1.citypeUuid
原始sql如(1)为什么报错,针对单个sql长度有限制吗,in参数的长度有要求吗?
sql中uuid每个都是32位。
已针对数据库做了如下参数调整:
“ALTER SYSTEM SET enable_record_trace_log=false;”
“SET GLOBAL ob_query_timeout = 600000000;”
“SET GLOBAL ob_sql_work_area_percentage=30;”
“ALTER SYSTEM SET enable_sql_audit=false;”
“ALTER SYSTEM SET enable_perf_event=false;”
“ALTER SYSTEM SET syslog_level=‘ERROR’;”
“SET GLOBAL ob_query_timeout=600000000;”
“SET GLOBAL ob_sql_work_area_percentage=30;”
“ALTER SYSTEM SET _preserve_order_for_pagination=true;”
“SET GLOBAL ob_enable_sql_audit=false;”
“SET GLOBAL max_allowed_packet=67108864;”
“ALTER proxyconfig SET proxy_mem_limited=‘6G’;”
“ALTER proxyconfig SET enable_compression_protocol=false;”