首批通过分布式安全可靠测评,为关键业务系统打造
OceanBase 数据库 V4.2.1 BP5 升级到 V4.2.1 BP7 版本卡在 Execute upgrade post script 的原因及解决方法
更新时间:2026-07-02 15:41
问题现象
OCP 升级在子任务 Execute upgrade post script 报错 NameError: global name 'MyError' is not defined。
[2024-06-03 18:31:49] ERROR do_upgrade_post.py:110 run error
Traceback (most recent call last):
File "/tmp/rpms/extract/oceanbase-4.2.1.7-107000112024052920.el7.x86_64.rpm/home/admin/oceanbase/etc/upgrade_post_extract_files_2024_06_03_18_31_23_741367_QbqkC9MP/do_upgrade_post.py", line 88, in do_upgrade
tenant_upgrade_action.do_upgrade(conn, cur, timeout, my_user, my_passwd)
File "/tmp/rpms/extract/oceanbase-4.2.1.7-107000112024052920.el7.x86_64.rpm/home/admin/oceanbase/etc/upgrade_post_extract_files_2024_06_03_18_31_23_741367_QbqkC9MP/tenant_upgrade_action.py", line 20, in do_upgrade
run_upgrade_job(conn, cur, "UPGRADE_ALL", timeout)
File "/tmp/rpms/extract/oceanbase-4.2.1.7-107000112024052920.el7.x86_64.rpm/home/admin/oceanbase/etc/upgrade_post_extract_files_2024_06_03_18_31_23_741367_QbqkC9MP/tenant_upgrade_action.py", line 249, in run_upgrade_job
check_upgrade_job_result(cur, job_name, timeout, max_used_job_id)
File "/tmp/rpms/extract/oceanbase-4.2.1.7-107000112024052920.el7.x86_64.rpm/home/admin/oceanbase/etc/upgrade_post_extract_files_2024_06_03_18_31_23_741367_QbqkC9MP/tenant_upgrade_action.py", line 216, in check_upgrade_job_result
raise MyError("execute upgrade job failed")
NameError: global name 'MyError' is not defined
问题原因
OceanBase 数据库 V2.1 BP2 升级到 V4.2.1 BP7 版本卡在 Execute upgrade post script,该 OceanBase 数据库 V4.2.1 BP5 版本是由更低版本升级上来的,任务报错原因为 4002,因用户之前使用 create or replace view 创建同名视图成功导致升级任务报错,查询任务语句在日志中有体现,如下所示。
[2024-06-03 18:31:38] INFO actions.py:146 use default timeout caculated by tenants, timeout(s):3600, tenant_count:5, timeout_per_tenant(s):100, min_timeout(s):3600
[2024-06-03 18:31:38] INFO tenant_upgrade_action.py:47 select job_status, rs_svr_ip, rs_svr_port, gmt_create from oceanbase.__all_rootservice_job
where job_type = 'UPGRADE_ALL' and job_id > 14 order by job_id desc limit 1
[2024-06-03 18:31:38] INFO tenant_upgrade_action.py:181 upgrade job not created yet
[2024-06-03 18:31:49] INFO tenant_upgrade_action.py:47 select job_status, rs_svr_ip, rs_svr_port, gmt_create from oceanbase.__all_rootservice_job
where job_type = 'UPGRADE_ALL' and job_id > 14 order by job_id desc limit 1
MySQL [oceanbase]> select * from oceanbase.__all_rootservice_job where job_type = 'UPGRADE_ALL' and job_id > 14 order by job_id desc limit 1\G;
*************************** 1. row ***************************
gmt_create: 2024-06-05 18:18:27.221929
gmt_modified: 2024-06-05 18:18:27.548278
job_id: 26
job_type: UPGRADE_ALL
job_status: FAILED
result_code: -4002
progress: 0
tenant_id: 0
tenant_name: NULL
database_id: NULL
database_name: NULL
table_id: NULL
table_name: NULL
partition_id: NULL
svr_ip: NULL
svr_port: NULL
unit_id: NULL
rs_svr_ip: xxx.xxx.xxx.xxx
rs_svr_port: 2882
sql_text: NULL
extra_info: TARGET_DATA_VERSION: '4.2.1.7'
resource_pool_id: NULL
tablegroup_id: NULL
tablegroup_name: NULL
问题的风险及影响
导致 OCP 升级任务卡在 Execute upgrade post script,无法正常升级
影响租户
影响 OceanBase 数据库中的 SYS 租户和 Oracle 租户以及 MySQL 租户。
适用版本
OceanBase 数据库 V4.2.1 BP7 之前版本。
解决方法
通过 drop view view_name 删除同名视图,然后重试升级任务。
规避方式
关闭 enable_sys_table_ddl。