During database operations, various exceptions may arise, such as application errors, connection issues, permission problems, resource limitations, and network disruptions. Among these, a common scenario is application exceptions where the error message contains an OceanBase error code.
To help you quickly identify the root cause and efficiently resolve such issues, this topic outlines a clear and practical troubleshooting process for application exceptions where error messages include OceanBase error codes. This process provides explicit steps to improve troubleshooting efficiency and minimize business impact, supporting daily operations.
Process description
When an application exception occurs and the error message contains OceanBase error codes, follow this process to troubleshoot the issue.
First, determine whether you can use OBClient to connect to the database and manually reproduce the issue:
If yes, you can then connect to the database after the issue is reproduced and proceed with further troubleshooting.
If no, you need to check the data source information in the program configuration.
Troubleshoot the issue by reproducing the issue
Use OBClient to connect to the OceanBase cluster by using port 2881 (the default port for SQL). If a custom port is used, replace the port number with the actual port number.
Manually execute the SQL statement that reported an error to reproduce the issue.
Execute the following statement to obtain the
trace_id.Notice
You must execute the following statement immediately after the SQL statement that reported an error is executed. Otherwise, the
trace_idof the error-reporting SQL statement cannot be obtained.MySQL-compatible modeOracle-compatible modeThe following statement is used to obtain the
trace_idin MySQL-compatible mode:obclient> SELECT last_trace_id();The following statement is used to obtain the
trace_idin Oracle-compatible mode:obclient> SELECT last_trace_id() FROM DUAL;Obtain the host information of the actual SQL execution.
OceanBase Database is usually deployed on multiple nodes. You can execute the following SQL statement to obtain the node where the SQL statement is actually executed, and then filter the logs.
MySQL-compatible modeOracle-compatible modeExecute the following statement in MySQL-compatible mode:
obclient> SELECT * FROM oceanbase.GV$OB_SQL_AUDIT WHERE trace_id=last_trace_id;In this statement, replace
last_trace_idwith thetrace_idobtained in the previous step.Execute the following statement in Oracle-compatible mode:
obclient> SELECT * FROM SYS.GV$OB_SQL_AUDIT WHERE trace_id=last_trace_id;In this statement, replace
last_trace_idwith thetrace_idobtained in the previous step.The host corresponding to
svr_ipin the query result of theGV$OB_SQL_AUDITview is the host that actually executed the SQL statement.Use the
sshcommand to log in to the host based on the obtained host information.Go to the directory where the logs are stored.
Take
/home/admin/oceanbaseas an example, which is the installation directory of OceanBase Database. In an actual environment, the log storage path may vary.cd /home/admin/oceanbase/logExecute the following command to filter relevant information from the logs.
grep "${trace_id}" observer.loggrep "${trace_id}" observer.log.xxxIn these statements, replace
${trace_id}with thetrace_idobtained in a previous step andobserver.log.xxxwith the log file that contains a timestamp. In this example,xxxneeds to be replaced with the actual timestamp based on the time when the SQL statement that reported an error is executed.Analyze the information provided by the logs, and take note of the error messages.
For more information about logs, see Overview of logs. If the information in the logs is unclear, contact technical support for assistance.
Troubleshoot data source configuration information
Specify the access path based on the data source.
Specify the number and addresses of the following components in the access path:
OceanBase Database Proxy (ODP) nodes
OBServer nodes
Determine whether the access path passes through ODP.
If yes, perform the following steps:
Use the
sshcommand to log in to the ODP node.Use the
cdcommand to go to the log directory of ODP. The logs of ODP are stored in the/logdirectory of its installation directory.Run the following command to filter out the error logs:
grep "Error text" obproxy_error.log obproxy_error.log.xxx | grep "Error time"Based on the filtered log entries, find the OBServer node that routes the erroneous SQL statement.
Use the
sshcommand to log in to the corresponding OBServer node for troubleshooting.
If no, perform the following steps:
Use the
sshcommand to log in to the OBServer node.Go to the directory where the logs are stored.
Here is an example: If the installation directory of OceanBase Database is
/home/admin/oceanbase, the logs are stored in the/home/admin/oceanbase/logdirectory. Please note that the actual path may vary based on your environment.cd /home/admin/oceanbase/logRun the following command to filter out the error logs:
grep "sending error" observer.log observer.log.xxx | grep "Error code"Based on the filtered log entries, obtain the trace_id, and then use the trace_id to filter the logs.
grep "trace id" observer.log observer.log.xxxAnalyze the problem based on the information provided in the logs and the relevant error prompts.
For more information about logs, see Overview of logs. If the information in the logs is unclear, contact technical support for assistance.