Git Product home page Git Product logo

raincat's Introduction

Codacy Badge Total lines License Maven Central QQ群

A strongly consistent distributed transaction framework

Modules

  • raincat-admin: Transaction log management background

  • raincat-annotation : Framework common annotation

  • raincat-common : Framework common class

  • raincat-core : Framework core package (annotation processing, log storage...)

  • raincat-dashboard : Management background front-end

  • raincat-dubbo : Support for the dubbo framework Less than 2.7 version

  • raincat-motan : Support for the motan rpc framework

  • raincat-springcloud : Support for the spring cloud rpc framework

  • raincat-spring-boot-starter : Support for the spring boot starter

  • raincat-sample : Examples using the raincat framework

Features

  • All spring versions are supported and Seamless integration

  • Provides support for the springcloud dubbo motan RPC framework

  • Provides integration of the spring boot starter approach

  • Support Nested transaction

  • Local transaction storage support : redis mongodb zookeeper file mysql

  • Transaction log serialization support : java hessian kryo protostuff

  • Spi extension : Users can customize the storage of serialization and transaction logs

Transaction Role

  • Transaction starter : @TxTransaction for The entry point of the first section

  • Transaction participant : Rpc invoker in the method (Add @TxTransaction)

  • Transaction coordinator : Coordinate the rollback of commit transactions

Raincat-Manager

It is the coordinator of the transaction and USES netty communication framework to communicate with participants and initiators.

Use eureka as a registry to support cluster deployment.

Use redis to store transaction information.

It has to start early.

Prerequisite

  • You must use jdk1.8 +

  • You must be a user of the spring framework

  • You must use one of the dubbo, motan, and springcloud RPC frameworks

About

raincat is A strongly consistent distributed transaction framework.

Good concurrency support, blocking spring transaction thread commit.

When the execution of the slice is complete and there is no exception,

the submission command is sent asynchronously by the coordinator to achieve strong consistency.

If you want to use it or get a quick look at it. Quick Start

Stargazers

Stargazers over time

Flow

Support

raincat's People

Contributors

0000005 avatar chaoscoffee avatar dependabot[bot] avatar xyzhimo avatar yu199195 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raincat's Issues

参与者handler中提交事务是若抛异常会导致数据不一致

ActorTxTransactionHandler代码第160行"platformTransactionManager.commit(transactionStatus);"参与者提交事务时如果抛异常,当前事务回滚,在finally中删除了本地补偿信息,这样就导致了当前服务的数据丢失,其他服务数据正常入库,且当前服务无法进行补偿

提一个边界性的问题

先赞叹一下,作者真大牛。

A调用了S1,S2,S3服务,运行正常进入提交事务的过程。S1提交正常,S2提交正常。但是提交S3的时候,可S3的网络出现问题,或者是S3对应的DB3数据库宕机

这个时候会陷入这样的境地,那就是S1,和S2的事务已经提交,没法回滚,也没有办法让S3提交。这个问题要怎么处理?

还有,本地服务的补偿,是一个什么样的机制呢?因为并没有看到关于补偿的介绍

raincat-admin起到的作用

raincat-manager起到事务协调器的作用的话
raincat-admin只是起到一个管理后台的作用吗? 为什么不把他们俩个合并成一个?
因为manager已经集成了eureka-server吗

【bug】id生成策略问题

idWorkerUtils中,使用此方法生成的id有重复的风险。
image
目前我在显示环境发现多次不同时间的事务,加到同一个事务组了。
image

嵌套调用的情下出现问题,如A-->B-->C

我测试了一下嵌套调用的情况,想问一下,为啥同一个事务活动中,却会创建两个事务组呢:
default

这里模拟的是 consumer调用order,order再调用stock。在这个嵌套调用中,是一次完整的事务活动,不应该属于同一个事务组吗?
如果同一次事务活动中创建了两个或以上的事务组的话,那么当出现了有的事务组成功,有的事务组失败的情况下,最终的这次事务活动是成功还是失败?事务管理器如何进行回滚?

raincat-admin 登录404

image

配置
application.yml

server:
   port: 8888
#   context-path: /admin

spring:
   application:
      name: raincat-admin
   profiles:
     active: db

tx:
  admin :
    userName : admin
    password : admin
  redis:
    hostName: localhost
    port : 6379
    #password:
    cluster : false
      # nodes: 127.0.0.1:70001;127.0.1:7002
      # redirects: 20

accept:
  apps:
    server:
      type[0]: property
      type[1]: eureka
      type[2]: unaccept
    eureka:
      url: http://localhost:9003/eureka
      intervalTime: 30

application-db.yml

recover:
   application:
      list : alipay-service,wechat-service,pay-service
   serializer :
      support: kryo
   retry :
      max: 10
   db:
      driver :  com.mysql.jdbc.Driver
      url: jdbc:mysql://172.20.100.205:3306/tx?useUnicode=true&characterEncoding=utf8
      username: root
      password: root

不支持选择指定的事务管理器。

Spring的 @Transactional 当在配置文件中有多个 TransactionManager , 可以用该属性transactionManager 指定选择哪个事务管理器。而目前 @TxTransaction 还不支持指定某个事务管理器。我这边提个pr,你看看

这个事务框架应该不能算是“二阶段提交”

作者你好,看了一下happylifeplat-transaction的实现,感觉你这个事务框架好像还不能算是“二阶段提交”啊。二阶段提交针对的是事务框架对资源管理器/数据库的协调过程,真正执行二阶段提交的应该还是底层的数据库。原理可以参考:二阶段提交原理图
而happylifeplat-transaction在提交事务时,采用的仍然是资源管理器的一阶段提交。只不过在发起提交之前,先判断了一下节点间网络通道的状态等信息,但这种框架自己内部的判断,应该不能算是一个提交的阶段啊。不然,二阶段提交岂不是分分钟改成三阶段提交了?二阶段、三阶段也就没啥太大差别、也不具备任何意义了。不知道我理解的对不对,求解惑~

tx-manager启动报错

需要加上配置我呢见
register-with-eureka: false
fetch-registry: false
否则会报错误
com-netflix-discovery-shared-transport-transportexception-cannot-execute-reques

BlockTask 类问题

BlockTask 类中的是否被唤醒标志Notify应去除static关键字,使之成为成员变量而不是类变量。目前使用static关键字,导致标志位Notify被修改一次变成true后,其他新生成的BlockTask对象的标志位Notify都是true.

如何使用集群

  • 两台 tx-manager 分别是
    172.20.101.46:8761; 172.20.101.93:8761;

  • nginx
    172.20.101.93:9761;

  • 使用文档中提供的demo,只是修改applicationContext.xml里的 <property name="txManagerUrl" value="http://172.20.101.93:9761"/>

  • 测试,停掉一台tx-manager
    客户端

2018-12-16 12:57:53.618  INFO 7172 --- [anagerLocator-1] o.d.r.c.service.impl.TxManagerLocator    : refresh updateTxManagerServices delayTime:60
2018-12-16 12:57:59.593 DEBUG 7172 --- [ntLoopGroup-3-7] o.d.r.c.n.h.NettyClientMessageHandler    : send tx manager heart beat!
2018-12-16 12:57:59.595 DEBUG 7172 --- [ntLoopGroup-3-7] o.d.r.c.n.h.NettyClientMessageHandler    : receive tx manage info :心跳
2018-12-16 12:58:09.594 DEBUG 7172 --- [ntLoopGroup-3-7] o.d.r.c.n.h.NettyClientMessageHandler    : send tx manager heart beat!
2018-12-16 12:58:09.595 DEBUG 7172 --- [ntLoopGroup-3-7] o.d.r.c.n.h.NettyClientMessageHandler    : receive tx manage info :心跳
2018-12-16 12:58:19.594 DEBUG 7172 --- [ntLoopGroup-3-7] o.d.r.c.n.h.NettyClientMessageHandler    : send tx manager heart beat!
2018-12-16 12:58:19.595 DEBUG 7172 --- [ntLoopGroup-3-7] o.d.r.c.n.h.NettyClientMessageHandler    : receive tx manage info :心跳

tx-manager

2018-12-16 12:59:48.699 DEBUG 1805 --- [ntLoopGroup-6-3] o.d.r.m.n.h.NettyServerMessageHandler    : receive client date this action:心跳
2018-12-16 12:59:49.181 DEBUG 1805 --- [ntLoopGroup-6-1] o.d.r.m.n.h.NettyServerMessageHandler    : receive client date this action:心跳
2018-12-16 12:59:49.298  INFO 1805 --- [a-EvictionTimer] c.n.e.registry.AbstractInstanceRegistry  : Running the evict task with compensationTime 1ms
2018-12-16 12:59:49.624 DEBUG 1805 --- [ntLoopGroup-6-2] o.d.r.m.n.h.NettyServerMessageHandler    : receive client date this action:心跳

再访问pay项目的swagger-ui里的save方法

{
  "timestamp": "2018-12-16T04:52:49.140+0000",
  "status": 500,
  "error": "Internal Server Error",
  "message": "TxManager connection ex!",
  "path": "/pay-service/pay/orderPay"
}
  • nginx的配置


worker_processes  1;

events {
    worker_connections  1024;
}


http {

     map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }

    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    upstream hi-linux-01.com {
        server 172.20.101.46:8761;
        server 172.20.101.93:8761;
    }

    server {
        listen       9761;
        server_name  172.20.101.94;

        location / {
              proxy_pass http://hi-linux-01.com;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection $connection_upgrade;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

  • 配置注册中心
eureka:
 client:
     serviceUrl:
       defaultZone: http://172.20.101.93:8761/eureka/,http://172.20.101.46:8761/eureka/

一阶段超时问题

consume 调 Order和Stock两个服务,一阶段调用Order超时,consume自己回滚本地事务,并通知TM回滚全局事务。TM通知Order回滚,但这个时候Order的异步线程还没有await,自然也就没有TM唤起来做rollback. Order的本地事务就一直悬挂在那里了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.