This topic describes how to troubleshoot database connection issues.
Applicable versions
The solution provided in this topic is applicable to all versions of OceanBase Database.
Troubleshooting logic
In normal cases, when you use an OBServer, an application to access OceanBase Database is connected to an application server, an ODP, and an OceanBase cluster in sequence. If the system architecture further contains load balancing, Domain Name System (DNS) resolution, and network components, the link from the application server to the OBServer node may be longer. You must understand the entire system architecture and check the complete connection link to successfully troubleshoot a database connection issue that occurs. Common connection issues include connection failures, unexpected disconnection, and connection exceptions. The issues may be caused by the following situations:
The connection between an ODP and an application is abnormal.
The connection between an ODP and an OBServer node is abnormal.
You can use the following methods for troubleshooting:
Check the availability of all components in the entire link and attempt to connect to each module to narrow down the scope where the issue is located.
Connect to OceanBase Database by using an ODP.
Directly connect to OceanBase Database.
Notice When you directly connect to OceanBase Database, the cluster name is not required, and the default port number is 2881. Sample command:
obclient -h$IP -uroot@sys -P2881 -p.
View the information about the issues.
View the application connection information and the background logs of OceanBase Database.
Common causes
Common scenarios of database connection issues:
The database transaction status is abnormal, and OceanBase Database is automatically disconnected.
Valid responses to a transaction commit request include
OB_SUCCESS,OB_TRANS_KILLED,OB_TRANS_CTX_NOT_EXIST,OB_TRANS_TIMEOUT,OB_TRANS_STMT_TIMEOUT,OB_TRANS_NEED_ROLLBACK,OB_TRANS_ROLLBACKED,OB_NOT_MASTER, andOB_TRANS_IS_EXITING. If another response is returned, OceanBase Database considers that the transaction status is unknown. In this case, OceanBase Database returns the-6225error code and thetransaction unknownerror message and is automatically disconnected. To avoid this situation, applications must capture exceptions, identify the transaction status, and handle exceptions to ensure that the business process meets expectations.An error occurs when a Java application attempts to connect to OceanBase Database.