---
title: OceanBase 数据库 V4.2.1 BP5 升级到 V4.2.1 BP7 版本卡在 Execute upgrade post script 的原因及解决方法-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于OceanBase 数据库 V4.2.1 BP5 升级到 V4.2.1 BP7 版本卡在 Execute upgrade post script 的原因及解决方法相关的常见问题和使用技巧，帮助您快速解决OceanBase 数据库 V4.2.1 BP5 升级到 V4.2.1 BP7 版本卡在 Execute upgrade post script 的原因及解决方法的难题。
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

划线反馈

# OceanBase 数据库 V4.2.1 BP5 升级到 V4.2.1 BP7 版本卡在 Execute upgrade post script 的原因及解决方法

更新时间：2026-07-02 15:41

适用版本： V4.2.x 内容类型：Troubleshoot  

## 问题现象

OCP 升级在子任务 Execute upgrade post script 报错 `NameError: global name 'MyError' is not defined`。

```shell
[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` 创建同名视图成功导致升级任务报错，查询任务语句在日志中有体现，如下所示。

```shell
[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

```

```shell
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`。

上一篇

[request change user 命令不兼容](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000002198926)

下一篇

[集群替换机器时卡住报错 4624 的原因和解决方法](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000003272539) ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
