SQL execution errors are common in database O&M and can directly impact business operations. Many factors can cause SQL execution errors, such as failed database connection, insufficient user privileges, syntax errors, or data not meeting query conditions.
To help you quickly identify the root cause and efficiently resolve SQL execution errors, the following sections provide a clear and practical troubleshooting process. This process offers specific steps to enhance issue resolution efficiency and minimize business impact, supporting your routine O&M work.
The following figure shows the SQL execution error troubleshooting process.

Procedure
You can troubleshoot the issue when an SQL execution error occurs, based on the following procedure.
After an SQL execution error occurs, view the SQL error message. If the error message contains an error code, troubleshoot the issue based on the error code. If the error message does not contain an error code, determine the error type. The error type can be an application execution error or an SQL execution error.
If the error is caused by application execution, search for information in the Knowledge Base to troubleshoot the issue.
If the error is caused by manual SQL execution, determine whether the error can be manually reproduced.
If the error cannot be reproduced, search for information in the Knowledge Base to troubleshoot the issue based on the SQL statement.
If the error can be reproduced, reproduce the error scenario. Connect to the OceanBase cluster through port 2881 or 2883 based on the original scenario and execute the original SQL statement to reproduce the error scenario.
After you reproduce the SQL execution error, perform the following steps to collect information for troubleshooting.
Execute the following statement to obtain
trace_id.Notice
You must execute the following statement immediately after the SQL statement that causes the error is executed; otherwise, the
trace_idobtained by executing the following statement does not belong to the SQL statement that causes the error.MySQL modeOracle modeThe statement to obtain
trace_idin MySQL mode is as follows:obclient> SELECT last_trace_id();The statement to obtain
trace_idin Oracle mode is as follows:obclient> SELECT last_trace_id() FROM DUAL;Obtain the host information on which the SQL statement is actually executed based on the obtained
trace_id.Generally, an OceanBase cluster is deployed across multiple nodes. You can execute the following statement to obtain the node on which the SQL statement is actually executed and then filter 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.Based on the query result in the
GV$OB_SQL_AUDITview, the host corresponding tosvr_ipis the host on which 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 specific log path depends on the actual environment.cd /home/admin/oceanbase/logExecute the following command to filter related logs.
grep "${trace_id}" observer.loggrep "${trace_id}" observer.log.xxxReplace
${trace_id}with thetrace_idobtained in the previous steps; replaceobserver.log.xxxwith a log file that contains timestamps based on the actual time when you reproduced the SQL execution error.Perform issue analysis based on the information provided in the logs, based on the error code or error message.
For more information about logs and error codes, see Overview of logs and Overview of error information.
If the information in the logs is unclear, contact technical engineers for assistance.
Case studies
The following case studies describe some typical scenarios where SQL execution errors occur.
After the SQL error is reproduced, the error code is returned in the result.
- When a
SELECTstatement contains manyORconditions, or manyAND-connectedINconditions, or manyAND NOTconditions, the database returns the error-4013, No memory or reach tenant memory limitwhen it executes the statement. For more information, see Error -4013 occurred in the SQL parsing phase, and the tenant memory is full.
- When a
The error code is included in the log.
When an
SQLstatement is executed to process alongtextfield, the errorErrorCode=5098is returned. For more information, see SQL error: Varchar value is too long for the column.When an SQL statement is executed, the error
error 4119 (RPC packet to send too long)is returned, and the informationobrpc packet payload execced its limitcan be found inobserver.logby using thetrace_id. For more information, see Error -4119 occurred: RPC packet to send too long.
Other error messages are included in the log.
- If the filter conditions in an SQL statement involve more than 64 fields, the error
-4002 Invalid argumentis returned. For more information, see An error of -4002 occurred in an SQL statement that involves filter conditions on more than 64 fields.
- If the filter conditions in an SQL statement involve more than 64 fields, the error
After the SQL error is reproduced, the error code is returned in the result.
- A query statement that contains the
c1,c2, andc3columns is executed. Thec1andc2columns hit indexes, and thec1orc2column contains multipleINexpressions.c1,c2, andc3columns form a vector expression. The statement returns aninternal errorwith the error codeORA-00600. For more information, see SQL error 4016 occurred in a statement that contains multiple IN expressions and a vector expression.
- A query statement that contains the
The error code is included in the log.
- When an SQL statement is executed, a
Timeouterror with the error codeORA-00600occurs. For more information, see SQL error: timeout.
- When an SQL statement is executed, a