目录
一、场景
1、对接民航电子数据库
2、将mysql数据库迁移到cae数据库
3、使用CAEMigrator
迁移工具进行数据库迁移时,该工具会卡死(不清楚是否是部署cae服务的服务器资源导致)
二、异常情况
在生成任务的时候就会卡死
三、排查
将以下sql分别在mysql5
和mysql8
数据库执行(随便哪个库),会出现不同的结果
以下SQL由民航电子数据库对接人员提供
sql
-- sql1
SELECT
*
FROM
information_schema.PARAMETERS;
-- sql2
SELECT
a.table_schema,
a.TABLE_NAME,
a.CONSTRAINT_name,
b.constraint_type,
a.column_name,
a.REFERENCED_TABLE_NAME,
REFERENCED_COLUMN_NAME,
c.UPDATE_RULE,
c.DELETE_RULE,
CASE
CONSTRAINT_TYPE
WHEN 'PRIMARY KEY' THEN
0
WHEN 'FOREIGN KEY' THEN
1
WHEN 'UNIQUE' THEN
2
WHEN 'CHECK' THEN
3 ELSE 4
END,
a.ORDINAL_POSITION
FROM
(
SELECT
table_schema,
TABLE_NAME,
CONSTRAINT_name,
upper(
GROUP_CONCAT( DISTINCT column_name )) AS column_name,
REFERENCED_TABLE_NAME,
upper(
GROUP_CONCAT( DISTINCT REFERENCED_COLUMN_NAME )) AS REFERENCED_COLUMN_NAME,
ORDINAL_POSITION
FROM
information_schema.KEY_COLUMN_USAGE
WHERE
table_schema = 'business0'
AND table_name = 't_aias_busiflowcfg'
GROUP BY
table_schema,
TABLE_NAME,
REFERENCED_TABLE_NAME,
CONSTRAINT_name,
ORDINAL_POSITION
) a
INNER JOIN ( SELECT TABLE_NAME, CONSTRAINT_NAME, constraint_type FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA = 'business0' AND TABLE_NAME = 't_aias_busiflowcfg' ) b ON a.constraint_name = b.constraint_name
AND a.table_name = b.table_name
LEFT JOIN ( SELECT CONSTRAINT_NAME, UPDATE_RULE, DELETE_RULE FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE TABLE_NAME = 't_aias_busiflowcfg' ) c ON a.CONSTRAINT_NAME = c.CONSTRAINT_NAME
ORDER BY
a.CONSTRAINT_name
-- sql3
SELECT DISTINCT
t.table_schema,
t.table_name,
CASE
WHEN p.partition_method = 'RANGE COLUMNS' THEN
'RANGE'
WHEN p.partition_method = 'LIST COLUMNS' THEN
'LIST' ELSE p.partition_method
END,
NULL,
p.partition_expression,
NULL,
count( p.partition_name ),
0,
NULL
FROM
INFORMATION_SCHEMA.TABLES t,
INFORMATION_SCHEMA.PARTITIONS p
WHERE
t.table_schema = p.table_schema
AND t.table_name = p.table_name
AND t.table_schema = 'business0'
AND t.table_name = 't_aias_busiflownodes'
AND t.create_options = 'partitioned'
GROUP BY
t.TABLE_SCHEMA,
t.table_name,
p.partition_method,
NULL,
p.PARTITION_EXPRESSION,
NULL,
p.partition_name
1、发现在迁移时,如果源数据库的版本是mysql5
则会卡死
2、发现在迁移时,如果源数据库版本是mysql8
则迁移正常
四、应急方案
如果需要迁移mysql5
版本的数据库,可以先把数据库复制一份到mysql8
,再从mysql8
迁移到cae