How Seata‑Golang Evolves Distributed Transactions for Cloud‑Native Environments

This article explains the fundamentals of distributed transactions, reviews the history and architectural challenges of the Seata‑Golang framework, and details its grpc‑based redesign, configuration steps, and the emerging Transaction Mesh concept integrated with Mosn for cloud‑native microservices.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
How Seata‑Golang Evolves Distributed Transactions for Cloud‑Native Environments

Distributed Transaction Model

A transaction manager (TM) initiates a global transaction with a transaction coordinator (TC). After business logic finishes, the TM asks the TC to commit or roll back the global transaction. Each resource manager (RM) registers a branch transaction with the TC and reports its local execution status. The TC, upon receiving a global commit or rollback request, notifies all successful RMs to perform the corresponding local commit or rollback.

Issues in Seata‑Golang v1 (released April 2020)

Bidirectional communication relies on the Getty network library, which stores client connection info in the TC for callbacks.

For high availability, each client must keep registration information for every TC instance and switch when a TC fails.

In Kubernetes, container restarts change IP addresses, so clients must discover TC endpoints via a service registry; the original design assumes static TC addresses.

The custom RPC protocol uses a proprietary encoding that is hard to extend and does not integrate well with cloud‑native ecosystems.

gRPC‑based v2 redesign (June 2023)

The v2 branch replaces the custom RPC with gRPC, making the protocol extensible and cloud‑native friendly. Clients are configured with two DNS entries: addressing – the client’s own service name and port (used by the TC for callbacks). serverAddressing – the TC’s service name and port (used by the client to discover the TC).

gRPC is used for both client‑to‑TC communication and TC‑to‑client callbacks. Example client configuration:

port: 8083                     # Branch transaction exposure port for TC callbacks
addressing: aggregation.default.svc:8083   # Client DNS name and port in Kubernetes
serverAddressing: seata.default.svc:8091   # TC DNS name and port in Kubernetes

Repository for the v2 implementation: https://github.com/opentrx/seata-golang/tree/v2

Transaction Mesh and Mosn Integration

To build a distributed‑transaction mesh, the TCC mode of Seata‑Golang has been integrated into Mosn, a Go‑based network proxy. The integration provides a reference architecture for a mesh of services and demonstrates how the gRPC interface defined in seata.proto can be used by other languages (e.g., C++). Pull request for the integration: https://github.com/mosn/mosn/pull/1728

Because Mosn is written in Go, it was chosen over Envoy (C++) for easier integration, while still offering a concrete example for developers who wish to implement a Transaction Mesh in other runtimes.

Key References

Seata official site: https://seata.io

Java Seata repository: https://github.com/seata/seata

Seata‑Golang project: https://github.com/opentrx/seata-golang

Go MySQL driver for Seata‑Golang: https://github.com/opentrx/mysql

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

cloud-nativeMicroservicesseata-golang
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.