【 TiDB 使用环境】生产环境 /测试/ Poc
【 TiDB 版本】
【复现路径】执行sql,直接oom
每次执行,必oom
sql:
SELECT tt.TABLE_SCHEMA, tt.TABLE_NAME, tt.CONSTRAINT_NAME, CONCAT_WS('\n', 库, 表, 条件, 忽略字段, 唯一, 任务名, 中文标识) conflunce, COLUMN_NAME
FROM (
SELECT t.TABLE_SCHEMA, t.TABLE_NAME, tc.CONSTRAINT_NAME,
concat('库:', t.TABLE_SCHEMA) 库, # 库:库名
concat('表:', t.TABLE_NAME) 表,# 表:表名
# where条件:where 条件 校验最近2个月的数据
if(dt.COLUMN_NAME IS null, '', concat('where ( ', dt.COLUMN_NAME, " >= CONVERT(concat(date_format(subdate(now(), INTERVAL 1 month), '%Y%m'), '01'), unsigned) AND", dt.COLUMN_NAME, " <= CONVERT(date_format(subdate(now(), INTERVAL 1 day), '%Y%m%d'), unsigned)) OR ( ", dt.COLUMN_NAME, ">= CONVERT(date_format(subdate(now(), INTERVAL 1 month), '%Y%m'), unsigned) AND ", dt.COLUMN_NAME, "<= CONVERT(date_format(subdate(now(), INTERVAL 1 day), '%Y%m'), unsigned)) OR ( ", dt.COLUMN_NAME, " >= CONVERT(date_format(subdate(now(), INTERVAL 1 day), '%Y'), unsigned))")) 条件,
# 忽略字段:i_id、d_created_at、d_updated_at
CONCAT_WS('、', '忽略字段:i_id、d_created_at、d_updated_at', GROUP_CONCAT(c.COLUMN_NAME SEPARATOR '、')) 忽略字段,
concat('唯一键列名字:', GROUP_CONCAT(cu.COLUMN_NAME)) 唯一, # 唯一键列名字:ch_batch_no
concat('任务名:prod_datacenter_', CONCAT_WS('_', t.TABLE_SCHEMA, t.TABLE_NAME, tc.CONSTRAINT_NAME)) 任务名, # 任务名:任务英文名,建议格式 prod_datacenter_{task_name}_xxx, 任务名要求唯一 t.TABLE_SCHEMA, t.TABLE_NAME
concat('任务中文标识:', CONCAT_WS('_', t.TABLE_COMMENT, t.TABLE_SCHEMA, t.TABLE_NAME, tc.CONSTRAINT_NAME)) 中文标识 # 任务中文标识:中文描述任务名,用于微信通知 t.TABLE_COMMENT, t.TABLE_NAME
,dt.COLUMN_NAME
FROM INFORMATION_SCHEMA.TABLES t
LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS tc
ON t.TABLE_SCHEMA = tc.TABLE_SCHEMA
AND t.TABLE_NAME = tc.TABLE_NAME
AND tc.CONSTRAINT_TYPE = 'UNIQUE'
LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS cu
ON tc.TABLE_SCHEMA = cu.TABLE_SCHEMA
AND tc.TABLE_NAME = cu.TABLE_NAME
AND tc.CONSTRAINT_SCHEMA = cu.CONSTRAINT_SCHEMA
AND tc.CONSTRAINT_NAME = cu.CONSTRAINT_NAME
LEFT JOIN INFORMATION_SCHEMA.COLUMNS c
ON t.TABLE_SCHEMA = c.TABLE_SCHEMA
AND t.TABLE_NAME = c.TABLE_NAME
AND c.DATA_TYPE in ('mediumblob','blob','longblob','json')
LEFT JOIN (
SELECT *
FROM (
SELECT a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, rank() over(PARTITION BY a.TABLE_SCHEMA, a.TABLE_NAME ORDER BY FIELD(a.COLUMN_NAME, 'I_DATE', 'I_MONTH', 'I_YEAR')) r
FROM INFORMATION_SCHEMA.COLUMNS a
WHERE a.COLUMN_NAME IN ('I_DATE', 'I_MONTH', 'I_YEAR')
) t
WHERE r = 1
) dt
ON t.TABLE_SCHEMA = dt.TABLE_SCHEMA
AND t.TABLE_NAME = dt.TABLE_NAME
WHERE t.TABLE_SCHEMA IN ('db1', 'db2', 'db3')
AND dt.COLUMN_NAME IS NOT null
GROUP BY t.TABLE_SCHEMA, t.TABLE_NAME, tc.CONSTRAINT_NAME
) tt;
【资源配置】
相关报错
[2023/07/27 16:40:29.442 +08:00] [INFO] [printer.go:33] ["Welcome to TiDB."] ["Release Versi
on"=v5.0.4] [Edition=Community] ["Git Commit Hash"=53251a9731da02ad9ee5abed9f27a14c7dea33a4]
["Git Branch"=heads/refs/tags/v5.0.4] ["UTC Build Time"="2021-09-14 08:56:02"] [GoVersion=g
o1.13] ["Race Enabled"=false] ["Check Table Before Drop"=false] ["TiKV Min Version"=v3.0.0-6
0965b006877ca7234adaced7890d7b029ed1306]
[2023/07/27 16:40:29.442 +08:00] [INFO] [trackerRecorder.go:28] ["Mem Profile Tracker starte
d"]