Overview

Seata is Alibaba’s open-source distributed transaction solution, formerly known as Fescar, aimed at making distributed transactions as simple and controllable as local transactions. Renamed to Seata (Simple Extensible Autonomous Transaction Architecture) in 2019.

Core Features

  • High Performance: Reduced performance loss through optimized transaction processing
  • Low Intrusion: Minimal changes to business code, easy to integrate
  • High Availability: Supports cluster deployment, ensuring service stability
  • Multi-language Support: Besides Java, also supports SDKs for Go, Python and other languages

Transaction Modes

Seata currently supports four transaction modes:

  1. AT Mode: Default transaction mode, essentially an optimized implementation of 2PC protocol
  2. TCC Mode: Transaction control implemented at business level, requires manual writing of Try, Confirm and Cancel
  3. Saga Mode: Long transaction solution, handles distributed transactions through event-driven approach
  4. XA Mode: Traditional distributed transaction implementation based on XA protocol

Architecture Components

Seata AT transaction model contains three core components:

TM (Transaction Manager)

  • Responsible for opening, committing or rolling back global transactions
  • Embedded in business applications as a jar package

RM (Resource Manager)

  • Responsible for branch transaction registration and status reporting
  • Manages local transaction resources (such as database connections)

TC (Transaction Coordinator)

  • Independently deployed server component
  • Maintains status of global transactions and branch transactions
  • Usually requires cluster deployment to ensure high availability

TM and RM Role Definitions

Global transaction initiator as TM:

  • Responsible for global transaction lifecycle management
  • Decides final status of global transaction based on business logic

Transaction participant as RM:

  • Each RM corresponds to a specific branch transaction
  • Needs to implement three basic interfaces: prepare/commit/rollback

AT Mode Two-Phase Commit

Phase One: Branch Transaction Commit

  1. TM starts global transaction, registers global transaction with TC
  2. RM executes branch transaction, records undo log
  3. Registers branch transaction with TC
  4. Commits local transaction

Phase Two: Global Transaction Resolution

  1. TC aggregates transaction status
  2. If all branch transactions succeed: TC asynchronously notifies each RM to delete undo log
  3. If any branch transaction fails: TC executes compensation operation based on undo log