During database operation, various exceptions may occur, such as application errors, database connection errors, database permission issues, database resource shortages, and network problems. One type of exception is application exceptions, where the error message contains an OceanBase error code.
To help you quickly identify the root cause of such exceptions and efficiently resolve them, this topic summarizes a clear and practical troubleshooting process for application exceptions with OceanBase error codes. This process provides specific steps to enhance troubleshooting efficiency and minimize business impact, supporting your daily O&M work.
Procedure
If an application fails to run and the error message contains an OceanBase error code, you can troubleshoot the issue by using the following procedure.
First, determine whether you can use OBClient to connect to the database and manually reproduce the issue:
If yes, connect to the database after the issue is reproduced and troubleshoot the issue.
If not, troubleshoot the data source information in the program configuration.
Troubleshoot the issue by reproducing it
Use OBClient to connect to the OceanBase cluster at port 2881 (the default SQL port). If you use a custom port, replace 2881 with the actual port number.
Manually execute the SQL statement that caused the 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 error is triggered; otherwise, the
trace_idof the SQL statement that caused the error cannot be obtained.MySQL modeOracle modeThe following example shows how to obtain the
trace_idin MySQL mode:obclient> SELECT last_trace_id();The following example shows how to obtain the
trace_idin Oracle mode:obclient> SELECT last_trace_id() FROM DUAL;Obtain the host information where the SQL statement is actually executed.
Generally, an OceanBase cluster has 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 modeOracle modeExecute the following statement in MySQL mode:
obclient> SELECT * FROM oceanbase.GV$OB_SQL_AUDIT WHERE trace_id=last_trace_id;Replace
last_trace_idwith thetrace_idobtained in the previous step.Execute the following statement in Oracle mode:
obclient> SELECT * FROM SYS.GV$OB_SQL_AUDIT WHERE trace_id=last_trace_id;Replace
last_trace_idwith thetrace_idobtained in the previous step.According to the query result of the
GV$OB_SQL_AUDITview, the host corresponding to thesvr_ipcolumn is the host where the SQL statement is actually executed.Use the
sshcommand to log in to the host based on the obtained host information.Go to the log directory.
Assume that the installation directory of OceanBase Database is
/home/admin/oceanbase. The following example shows how to go to the log directory. The timestamped log file name,observer.log.xxx, is used in the following examples. Replacexxxwith the actual timestamp based on the time when the SQL statement caused the error during the reproduction.cd /home/admin/oceanbase/logRun the following command to filter the required information from the logs.
grep "${trace_id}" observer.loggrep "${trace_id}" observer.log.xxxReplace
${trace_id}with thetrace_idobtained in the previous steps; replaceobserver.log.xxxwith the actual timestamped log file name.Analyze the issue based on the information provided in the logs and the error message.
For more information about logs, see Log overview. If the information in the logs is unclear, contact technical support for assistance.
Troubleshoot the data source configuration
Based on the data source, identify the access path.
The access path contains the following information:
The number and IP addresses of OBProxies
The number and IP addresses of OBServer hosts
Determine whether OBProxy is involved.
If yes, follow these steps to troubleshoot the issue:
Run the
sshcommand to log in to the corresponding OBProxy node.Run the
cdcommand to go to the log directory of OBProxy. The OBProxy logs are stored in the/logdirectory under 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"Identify the OBServer host that the error SQL statement is routed to based on the filtered log entries.
Run the
sshcommand to log in to the corresponding OBServer host for troubleshooting.
If not, follow these steps to troubleshoot the issue:
Run the
sshcommand to log in to the corresponding OBProxy node.Go to the log directory.
Assume that the installation directory of OceanBase Database is
/home/admin/oceanbase. The specific log path depends on your actual setup.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"Obtain the trace_id from the filtered logs and then filter the logs again using trace_id.
grep "trace id" observer.log observer.log.xxxAnalyze the issue based on the information provided in the logs and the error messages.
For more information about logs, see Overview. If the logs are unclear, contact technical support for assistance.
Case studies
A regular user of a regular business tenant encountered the
ERROR 1040 (08004): Too many connectionserror when directly connecting to OceanBase Database on port 2881.In scenarios with frequent connection establishment and termination, an error 4016 was returned when the total number of established connections reached a certain threshold.
- An application encountered error 00918 when executing an INSERT statement.
- An error
ORA-00600: internal error code, arguments: -4007, Not supported feature or functionwas encountered when accessing a large object (LOB) type through a database link in OceanBase Database.