Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
D

dtm

> 数据库
Open source

A distributed transaction framework, supports workflow, saga, tcc, xa, 2-phase message, outbox patterns, supports many languages.

10.9K stars0 likes3 views
WebsiteGitHub

About

A distributed transaction framework, supports workflow, saga, tcc, xa, 2-phase message, outbox patterns, supports many languages.

English | 简体中文

Distributed Transactions Manager

What is DTM

DTM is a distributed transaction framework which provides cross-service eventual data consistency. It provides saga, tcc, xa, 2-phase message, outbox, workflow patterns for a variety of application scenarios. It also supports multiple languages and multiple store engine to form up a transaction as following:

Who's using DTM (partial)

Tencent

Bytedance

Ivydad

More

Features

  • Support for multiple transaction modes: SAGA, TCC, XA, Workflow, Outbox
  • Multiple languages support: SDK for Go, Java, PHP, C#, Python, Nodejs
  • Better Outbox: 2-phase messages, a more elegant solution than Outbox, support multi-databases
  • Multiple database transaction support: MySQL/MariaDB, Redis, MongoDB, Postgres, TDSQL, etc.
  • Support for multiple storage engines: MySQL/MariaDB (common), Redis (high performance), BoltDB (dev&test), MongoDB (under planning)
  • Support for multiple microservices architectures: go-zero, go-kratos/kratos, polarismesh/polaris
  • Support for high availability and easy horizontal scaling

Application scenarios.

DTM can be applied to data consistency issues in a large number of scenarios, here are a few common ones

  • cache management: thoroughly guarantee the cache final consistency and strong consistency
  • flash-sales to deduct inventory: in extreme cases, it is also possible to ensure that the precise inventory in Redis is exactly the same as the final order created, without the need for manual adjustment
  • Non-monolithic order system: Dramatically simplifies the architecture
  • Event publishing/subscription: better outbox pattern

Cook Book

Quick start

run dtm

bash
git clone https://github.com/dtm-labs/dtm && cd dtm
go run main.go

Start an example

Suppose we want to perform an inter-bank transfer. The operations of transfer out (TransOut) and transfer in (TransIn) are coded in separate micro-services.

Here is an example to illustrate a solution of dtm to this problem:

bash
git clone https://github.com/dtm-labs/quick-start-sample.git && cd quick-start-sample/workflow-grpc
go run main.go

Code

Usage

…

When the above code runs, we can see in the console that services TransOut, TransIn has been called.

Rollback upon failure

If any forward operation fails, DTM invokes the corresponding compensating operation of each sub-transaction to roll back, after which the transaction is successfully rolled back.

Let's purposely trigger the failure of the second sub-transaction and watch what happens

go
// req := busi.BusiReq{Amount: 30, TransInResult: ""}
req := busi.BusiReq{Amount: 30, TransInResult: "FAILURE"}
})

we can see in the console that services TransOut, TransIn, TransOutRevert has been called

More examples

If you want more quick start examples, please refer to dtm-labs/quick-start-sample

The above example mainly demonstrates the flow of a distributed transaction. More on this, including practical examples of how to interact with an actual database, how to do compensation, how to do rollback, etc. please refer to dtm-examples for more examples.

Give a star! ⭐

If you think this project is interesting, or helpful to you, please give a star!

Issues· 88 open

View all issuesOpen on GitHub
  • #584

    go版本的client SDK版本号有点混乱是否可以整理一下呢

    Updated Sep 20, 2026
  • #583

    Vulnerability in dtm project

    Updated Apr 21, 2026
  • #582

    Are there plans to wrap DTM as an MCP server for AI integration, following the model of go-zero's mcp-zero?

    Updated Mar 6, 2026
  • #581

    go client install

    Updated Feb 21, 2026
  • #580

    en.dtm.pub TLS certificate appears valid (could not reproduce issue)

    Updated Feb 18, 2026
  • #572

    workflow other error can't backoff retery and RetryInterval is invalid

    Updated Jan 27, 2026
  • #519

    Saga模式下,分支事务超时问题

    Updated Jan 27, 2026
  • #525

    是否可以支持nacos和goframe

    Updated Jan 27, 2026
  • #548

    gozero的rpc直连dtm,执行事务时错误

    Updated Jan 27, 2026
  • #575

    dtm 中 driver 为 postgres ,如何指定sslmode ?

    Updated Jan 6, 2026

> Tags

Gocadencecsharpdatabasedistributed

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category数据库
PricingOpen source

> Related tools

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库