本文为您介绍使用 OceanBase 迁移服务(OceanBase Migration Service,OMS)进行全量迁移时,索引迁移一直没有进展的原因和解决方法。
适用版本
适用于 OceanBase 数据库 V3.x 和 V4.x。
问题描述
问题一:迁移 MySQL 数据库的数据至 OceanBase 数据库 MySQL 兼容模式时,全量迁移步骤的索引迁移一直没有进展。暂停数据迁移任务并重新启动后,没有产生新日志。暂停 OMS 容器并重启后,也没有产生新日志及进展。

查看组件监控无异常:

查看各组件状态显示正常:

问题二:部分数据迁移任务报错如下。
com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 368127, active 60, maxActive 60
关键信息
查看 OMS 日志。
docker exec -it oms bash cd /home/admin/logs/ghana/Ghana tail -f *.log|grep -E '==|DDLs concurrent number is too much|skip this scheduler'发现有
DDLs concurrent number is too much提示并发过大的信息。==> oms-scheduler.log <== ... 2024-11-25 09:54:11.348 [INFO] [getAndExecuteDDLForObjectsExecutor-18] [a9bd61db-44e3-4f53-82ae-6f1cxxxx] DDLs concurrent number is too much, just skip this scheduler. project id np_69gjfsq2e61s, task id 1859873303511334914登录容器,进入 OMS Meta 租户查询。
docker exec -it oms bash mysql -h10.10.10.1 -P2883 -uxxxx@oms_xxxx#mexxxx -pxxxx -A -Doms_rm在页面查看
project_id或根据如下 SQL 查询project_id。MySQL [oms_rm]> select id,name,type,status,gmt_create,gmt_finish from project where status NOT IN ('FINISHED','RELEASED') order by gmt_create; +-----------------+-------------+-----------+----------+---------------------+---------------------+ | id | name | type | status | gmt_start | gmt_finish | +-----------------+-------------+-----------+----------+---------------------+---------------------+ | np_69gg53h59veo | perf_1 | MIGRATION | RUNNING | 2024-11-26 14:03:33 | NULL | ...根据
project_id查询oms_step,可以在extra_info看出报错信息或在step_info中找到jobId。MySQL [oms_rm]> select * from oms_step where project_id = 'np_69ggxxxx' and is_show = 1 and step_status = 'RUNNING'\G *************************** 1. row *************************** id: s_69gg54arkj0i project_id: np_69gxxxx step_order: 4 step_name: INDEX_TRANSFER step_desc: 索引迁移 step_status: RUNNING step_info: {"jobId":"1859864001039990785"} is_show: 1 extra_info: {"failedTime":"2024-11-23T02:31:23.867"} start_time: 2024-11-22 15:45:55 finish_time: 2024-11-25 12:00:33 gmt_create: 2024-11-22 15:38:20 gmt_modified: 2024-11-25 12:01:16 step_progress: 64 remaining_seconds: -1 retry_count: 0 interactive: 0 1 row in set (0.001 sec)MySQL [oms_rm]> select * from oms_step where project_id = 'np_69gjls8xzznl' and is_show = 1 and step_status NOT IN ('FINISHED','INIT')\G *************************** 1. row *************************** id: s_69gjlxxxx project_id: np_69gjlsxxxx step_order: 4 step_name: INDEX_TRANSFER step_desc: 索引迁移 step_status: SUSPEND step_info: {"jobId":"18598737695xxxx"} is_show: 1 extra_info: {"errorCode":"INNER_ERROR","errorMsg":"nested exception is org.apache.ibatis.exceptions.PersistenceException: \n### Error updating database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 431990, active 60, maxActive 60, creating 0\n### The error may exist in com/alipay/oms/common/dal/mapper/migrate/OmsStructMigrationRecordMapper.java (best guess)\n### The error may involve com.alipay.oms.common.dal.mapper.migrate.OmsStructMigrationRecordMapper.updateById\n### The error occurred while executing an update\n### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException: wait millis 431990, active 60, maxActive 60, creating 0","failedTime":"2024-11-23T02:53:30.205"} start_time: 2024-11-22 17:14:54 finish_time: 2024-11-25 10:13:03 gmt_create: 2024-11-22 16:17:09 gmt_modified: 2024-11-25 10:13:02 step_progress: 73 remaining_seconds: -1 retry_count: 0 interactive: 0 1 row in set (0.001 sec)从 extra_info 可以看到 OMS 连接 MetaDB 失败,从连接池获取链接超时。
org.springframework.jdbc.CannotGetJdbcConnectionException;Failed to obtain JDBC Connection; nested exception is com.alibaba.druid.pool.GetConnectionTimeoutException;wait millis 431990, active 60, maxActive 60, creating 0
问题原因
同时运行 3 个以上的数据迁移任务(每个任务迁移 10 万张表),创建索引的并发请求数据过高。
OMS 连接 MetaDB 的连接池满。
影响租户
影响 OceanBase 数据库中的 Oracle 兼容模式租户和 MySQL 兼容模式租户,对于 SYS 租户无影响。
解决方法
存在多个数据迁移任务并且迁移对象较多(例如本文示例中迁移任务大于 4 个,每个任务迁移 10 万张表)时,可能导致索引迁移无进展或 OMS 连接 MetaDB 的连接池满,相应的解决方法如下。
索引迁移无进展
对于创建索引并发请求数量过大,导致索引迁移无进展的情况,您可以尝试在 系统参数 页面搜索 struct.transfer.config,并调小 project.index.execute.batch.size 或调大 project.index.execute.max.parallel。

然后根据 oms_step. step_info 中的 jobId 查询 oms_struct_migration_record,结果如下。
MySQL [oms_rm]> select obj_type,post_script_executed,record_status,count(1) from oms_struct_migration_record where task_id = '18598640010xxxx' group by obj_type,record_status,post_script_executed ORDER BY obj_type,record_status,post_script_executed;
+----------+----------------------+----------------------+----------+
| obj_type | post_script_executed | record_status | count(1) |
+----------+----------------------+----------------------+----------+
| index | 0 | APPLYING | 71 |
| index | 0 | FINISHED | 2541 |
| index | 0 | READY | 26493 |
| schema | 0 | FINISHED | 21 |
| table | 1 | FINISHED | 9543 |
| table | 1 | FINISHED_HAS_CONVERT | 9 |
+----------+----------------------+----------------------+----------+
6 rows in set (0.321 sec)
可以看到 obj_type 为 index 且 record_status 为 APPLYING 的较多,将 record_status 为 APPLYING 的改为 READY(自动进入队列重新调度)或 APPLY_FAILED(最后需要手动点恢复重新执行),建议加 limit 以避免多更新数据。
update oms_struct_migration_record
set record_status='READY' where task_id = '185986400103xxxx' and obj_type = 'index' and record_status in ('APPLYING') limit 71;
OMS 将按照新的设置重新调度 DDL 任务。修改后持续查询并观察进展变化。
OMS 连接 MetaDB 的连接池满
对于 OMS 连接 MetaDB 的连接池满的情况,您可以在 OMS Docker 中修改如下参数。
docker exec -it oms bash
[root@ocp ~]# grep maxTotal /home/ds/ghana/config/application-oms.properties
maxTotal=120
然后重启 oms_console(请勿重启 OMS 容器以避免参数修改丢失)。
supervisorctl restart oms_console
规避方式
您可以通过以下三种方式对该类问题的出现进行规避。
减少数据迁移任务的数量。
减少数据迁移任务中迁移对象的数量。
在 OMS 迁移非大表时,选择不允许索引后置,先创建索引再迁移数据。
