OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.3.1

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.3.1
    iconOceanBase Database
    SQL - V 4.3.1
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    SQL
    KV
    • V 4.6.0
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    Transaction rollbacks

    Last Updated:2026-04-15 08:25:14  Updated
    Share
    What is on this page
    Share

    The following table describes the errors that indicate the rollback of a transaction.

    External error code
    Internal error code
    Error message
    6002 -6224 transaction need rollback
    6002 -6223 Transaction exiting
    6002 -6211 Transaction is killed
    6002 -6213 Transaction context does not exist

    A transaction rollback is not necessarily an error, but sometimes the result of an event such as a transaction timeout or a leader switchover of participants.

    A leader switchover is performed in the following scenarios:

    • You run an O&M command to, for example, switch the replica leader, change the primary zone, remove a server, or stop a server.
    • An internal scheduling task is performed, such as migrating units, bringing replicas offline, and generating replicas in the primary zone.
    • A certain internal exception occurs.

    If RootService triggers a leader switchover, the system denies the start of new transactions and waits some time for the existing active transactions to be completed. After the wait period elapses, the system migrates uncompleted transactions to the new leader and executes the leader switchover. Then, the new leader starts to provide services.

    In the following scenarios, transactions are killed:

    • The leader switchover is not triggered by RootService but by certain exceptions.
    • Large transactions are in progress.
    • The execution of statements has not been completed when uncompleted transactions are being migrated to the new leader.

    When a transaction rollback error occurs, you can check whether a leader switchover is performed by using the DBA_OB_SERVER_EVENT_HISTORY view. The following example describes a leader switchover process triggered by running the switch replica leader command.

    1. Query the distribution of log stream leaders before the leader switchover.

      obclient>
      select TENANT_ID,LS_ID,SVR_IP,SVR_PORT,ROLE,PAXOS_MEMBER_LIST from GV$OB_LOG_STAT where tenant_id=1 and ls_id=1;
      +-----------+-------+-------------+----------+----------+---------------------------------------------------------------------------+
      | TENANT_ID | LS_ID | SVR_IP      | SVR_PORT | ROLE     | PAXOS_MEMBER_LIST                                                         |
      +-----------+-------+-------------+----------+----------+---------------------------------------------------------------------------+
      |         1 |     1 | xx.xx.xx.158|     2882 | FOLLOWER | xx.xx.xx.43:2882:1686125578254268,xx.xx.xx.106:2882:1,xx.xx.xx.158:2882:1 |
      |         1 |     1 | xx.xx.xx.43 |     2882 | FOLLOWER | xx.xx.xx.43:2882:1686125578254268,xx.xx.xx.106:2882:1,xx.xx.xx.158:2882:1 |
      |         1 |     1 | xx.xx.xx.106|     2882 | LEADER   | xx.xx.xx.43:2882:1686125578254268,xx.xx.xx.106:2882:1,xx.xx.xx.158:2882:1 |
      +-----------+-------+-------------+----------+----------+---------------------------------------------------------------------------+
      3 rows in set (0.01 sec)
      
    2. Execute the leader switchover.

      obclient>
      alter system switch replica leader ls=1 server='xx.xx.xx.158:2882' tenant='sys';
      Query OK, 0 rows affected (0.01 sec)
      
    3. Query the events involved in the leader election of log streams.

      obclient>
      SELECT VALUE4 HAPPENED_TIME,svr_ip,VALUE1 TENANT_ID,VALUE2 LS_ID,event,name3,value3  FROM DBA_OB_SERVER_EVENT_HISTORY  WHERE module="ELECTION";
      +----------------------------+-------------+-----------+-------+---------------------------+-------+------------------------------------------------------------------------------------------------------------------+
      | HAPPENED_TIME              | svr_ip      | TENANT_ID | LS_ID | event                     | name3 | value3                                                                                                           |
      +----------------------------+-------------+-----------+-------+---------------------------+-------+------------------------------------------------------------------------------------------------------------------+
      | 2023-06-12 23:27:23.291335 | xx.xx.xx.106| 1         | 1     | prepare change leader     | INFO  | leader prepare to change leader : "xx.xx.xx.106:2882" -> "xx.xx.xx.158:2882", reason : MANUAL LEADER             |
      | 2023-06-12 23:27:23.294363 | xx.xx.xx.158| 1         | 1     | change leader to takeover | INFO  | new leader takeover : "xx.xx.xx.106:2882" -> "xx.xx.xx.158:2882"                                                 |
      | 2023-06-12 23:27:23.318691 | xx.xx.xx.43 | 1         | 1     | witness change leader     | INFO  | witness change leader : "xx.xx.xx.106:2882" -> "xx.xx.xx.158:2882"                                               |
      | 2023-06-12 23:27:23.292954 | xx.xx.xx.106| 1         | 1     | change leader to revoke   | INFO  | old leader revoke : "xx.xx.xx.106:2882" -> "xx.xx.xx.158:2882"                                                   |
      | 2023-06-12 23:27:23.541978 | xx.xx.xx.158| 1         | 1     | witness change leader     | INFO  | witness change leader : "xx.xx.xx.106:2882" -> "xx.xx.xx.158:2882"                                               |
      | 2023-06-12 23:27:23.542136 | xx.xx.xx.106| 1         | 1     | witness change leader     | INFO  | witness change leader : "xx.xx.xx.106:2882" -> "xx.xx.xx.158:2882"                                               |
      +----------------------------+-------------+-----------+-------+---------------------------+-------+------------------------------------------------------------------------------------------------------------------+
      6 rows in set (0.02 sec)
      

    Previous topic

    Transaction-related errors
    Last

    Next topic

    Long-running transactions
    Next