OceanBase Database executes a transaction request sent from a client and returns the result to the client. If the transaction execution fails or encounters an exception, an error is reported. Common transaction errors are classified into two types: errors that are thrown to the client during transaction execution and errors that are recorded in system logs or internal views. This topic describes frequently used methods for troubleshooting these two types of errors to help you identify common transaction issues.
Troubleshooting methods
To troubleshoot common transaction errors, query the transaction status table and check the system logs.
The GV$OB_TRANSACTION_PARTICIPANTS view displays the context of participants in transactions that are not terminated on the leader and follower nodes. You need to collect the information of all transaction participants to confirm the execution status of the current transaction. The key fields are described as follows:
TX_TYPE: The value of this field on the leader node isUNDECIDEDduring transaction execution, and indicates the type of the transaction, such asLOCALorDISTRIBUTEDduring transaction commit.STATE: the status of the transaction. The value isACTIVEduring transaction execution.ACTION: The value of this field on the leader node isSTARTduring transaction execution andCOMMITduring transaction commit.
The following example displays the information about some transactions that are in execution:
obclient> select * from gv$ob_transaction_participants\G
*************************** 1. row ***************************
TENANT_ID: 1002
SVR_IP: 11.xx.xx.xx
SVR_PORT: 48274
SESSION_ID: 3221506881
SCHEDULER_ADDR: "11.xx.xx.xx:48270"
TX_TYPE: UNDECIDED
TX_ID: 752
LS_ID: 1002
PARTICIPANTS: NULL
CTX_CREATE_TIME: 2022-09-21 16:28:46.037405
TX_EXPIRED_TIME: 2022-09-21 16:43:37.804879
STATE: ACTIVE
ACTION: START
PENDING_LOG_SIZE: 57
FLUSHED_LOG_SIZE: 0
ROLE: LEADER
*************************** 2. row ***************************
TENANT_ID: 1002
SVR_IP: 11.xx.xx.xx
SVR_PORT: 48270
SESSION_ID: 3221506881
SCHEDULER_ADDR: "11.xx.xx.xx:48270"
TX_TYPE: UNDECIDED
TX_ID: 752
LS_ID: 1001
PARTICIPANTS: NULL
CTX_CREATE_TIME: 2022-09-21 16:28:37.804879
TX_EXPIRED_TIME: 2022-09-21 16:43:37.804879
STATE: ACTIVE
ACTION: START
PENDING_LOG_SIZE: 57
FLUSHED_LOG_SIZE: 0
ROLE: LEADER
If you choose to check the system logs, you can use the trace ID to search for logs within the corresponding period in the log file of the OBServer node. This way, you can view all logs related to the execution of a statement. You can also use the transaction ID to search for all logs related to the transaction.