ob_error

2024-06-28 05:30:29  Updated

ob_error is an error code parsing tool of OceanBase Database. ob_error returns the corresponding causes and solutions for each error code you entered. With ob_error, you can get basic error information without looking up the documentation.

Install ob_error

Install ob_error by using YUM commands

You can use YUM commands to directly install OceanBase Utils and then use ob_error.

yum-config-manager --add-repo https://mirrors.aliyun.com/oceanbase/OceanBase.repo
yum install oceanbase-ce-utils

Install ob_error by using the OceanBase Utils installation package

You can install OceanBase Utils and then use ob_error.

  1. Search for OceanBase Utils in the OceanBase Download Center and then download the required version to your local server.

  2. Run the following command in the file directory to install OceanBase Utils.

    rpm -ivh  oceanbase-ce-utils-<version>
    

    If you only need ob_error, run the rpm2cpio command to obtain ob_error.

    rpm2cpio oceanbase-ce-utils-<version> | cpio -idmv ./usr/bin/ob_error
    cp usr/bin/ob_error /usr/local/bin
    

Build ob_error by compiling the source code

You can compile the source code of OceanBase Database to build ob_error.

  1. Clone the open-source code of OceanBase Database to your local server.

    git clone https://github.com/oceanbase/oceanbase
    
  2. Compile ob_error in the following modes:

    • Debug mode

      bash build.sh debug --init
      cd build_debug
      make ob_error
      cp tools/ob_error/src/ob_error /usr/local/bin
      

      By default, after you compile ob_error, you can find the compiled files in the DEBUG_BUILD_DIR/tools/ob_error/src/ob_error directory. DEBUG_BUILD_DIR indicates the compilation directory, which is build_debug in this example.

    • Release mode

      bash build.sh release --init
      cd build_release
      make ob_error
      cp tools/ob_error/src/ob_error /usr/local/bin
      

      By default, after you compile ob_error, you can find the compiled files in the RELEASE_BUILD_DIR/tools/ob_error/src/ob_error directory. RELEASE_BUILD_DIRR indicates the compilation directory, which is build_release in this example.

Use ob_error

General query format

When you enter an error code, ob_error automatically returns an error message corresponding to the operating system, Oracle mode, MySQL mode, and OceanBase Database. Here is an example:

$ob_error 4001
OceanBase:
    OceanBase Error Code: OB_OBJ_TYPE_ERROR(-4001)
    Message: Object type error
    Cause: Internal Error
    Solution: Contact OceanBase Support
Oracle:
    Oracle Error Code: ORA-04001
    Message: sequence parameter must be an integer
    Related OceanBase Error Code:
        OB_ERR_SEQ_OPTION_MUST_BE_INTEGER(-4317)

Specified query mode

You can search for the error code of a specific mode by adding a prefix, also known as a facility, to the ob_error command.

  • When you add the my facility, if the error code is not generated for an error in MySQL mode but exists in OceanBase Database, ob_error returns an error message of OceanBase Database. Otherwise, ob_error returns an error message in MySQL mode.

    $ob_error my 4000
    
    OceanBase:
        OceanBase Error Code: OB_ERROR(-4000)
        Message: Common error
        Cause: Internal Error
        Solution: Contact OceanBase Support
    
    $ob_error my 1210
    
    MySQL:
        MySQL Error Code: 1210 (HY000)
        Message: Invalid argument
        Message: Miss argument
        Message: Incorrect arguments to ESCAPE
        Related OceanBase Error Code:
            OB_INVALID_ARGUMENT(-4002)
            OB_MISS_ARGUMENT(-4277)
            INCORRECT_ARGUMENTS_TO_ESCAPE(-5832)
    
  • If you have added the ora or pls facility, ob_error returns an error message of the Oracle mode if the error code exists in this mode.

    $ob_error ora 51
    Oracle:
        Oracle Error Code: ORA-00051
        Message: timeout occurred while waiting for a resource
        Related OceanBase Error Code:
            OB_ERR_TIMEOUT_ON_RESOURCE(-5848)
    
  • When you use the -a option in some circumstances, if the error code you entered exists in the corresponding mode, ob_error returns error messages of both OceanBase Database and the Oracle mode.

    $ob_error ora 600 -a 5727
    OceanBase:
        OceanBase Error Code: OB_ERR_PROXY_REROUTE(-5727)
        Message: SQL request should be rerouted
        Cause: Internal Error
        Solution: Contact OceanBase Support
    Oracle:
        Oracle Error Code: ORA-00600
        Message: internal error code, arguments: -5727, SQL request should be rerouted
        Related OceanBase Error Code:
            OB_ERR_PROXY_REROUTE(-5727)
    

    Note

    You can use the -a option to locate the ORA-00600 error with variables. The ORA-00600 error is an internal error of Oracle.

More examples

For more test cases, see expect_result.

You can also run the --help command to get a complete user guide.

ob_error --help

Add error causes and solutions

Note

This section can be used by developers for reference.

This section describes how to add error causes and solutions for the reference of developers.

Example

The error code 4000 in the src/oberror_errno.def file is defined as follows:

DEFINE_ERROR(OB_ERROR, -4000, -1, "HY000", "Common error");

To add causes and solutions, you can redefine it as follows:

DEFINE_ERROR(OB_ERROR, -4000, -1, "HY000", "Common error", "CAUSE", "SOLUTION");

Run the following command to regenerate src/lib/ob_errno.h, src/share/ob_errno.h, and src/share/ob_errno.cpp:

cd src/share
./gen_errno.pl

Recompile ob_error in the BUILD_DIR directory.

Contact Us