当前位置:网站首页>Distributed transaction solution
Distributed transaction solution
2022-06-25 15:25:00 【Running pig ZC】
background
In the microservices architecture , Suppose the following calls exist A->B, stay A call B There were some operations before C, If C success , call B Failure , At this point, you can roll back the transaction , But if you call first B And successful , Then do the operation C failed , So what to do ?

- B Provide an interface for reverse operation ( It doesn't have to be solved )
- Business compensation
- Transaction message
Implementation scheme
Transaction compensation mechanism
The basic principle

explain
In system A Start a transaction , In business , First operate the database of the system a, At the same time to the database a Insert a compensation task , Commit transaction ; The task has three states ,
The three states of the task 1: To be processed , 2: In processing ,3: Processing is complete
Start a task externally , Used to pull up the transaction compensation task ( Status as 1: To be processed ), The change status is in process
Get the corresponding data , The change status is in process , Interface to call the system B, If it doesn't work ( There is an error ) Change the original compensation task status to 1, If successful, it will be changed to processing completion , The processing result of the current scheduled task is 1 For the next scheduling pull up
Transaction message
The basic principle
Use here rocketMQ, The thought is Two-phase commit + Transaction status check

explain
- Send a transactional message , By current JVM launch ( The first stage )
- broker Feedback to current JVM( be based on ACK)
- Perform the operation C
- Follow the instructions C To determine whether to commit news , still rollback news ( The second stage )
- When mq Of broker A sender who has not received a message for a long time ( At present JVM) Sent Commit/Rollback When instructed by , Transaction status needs to be checked back
- At present JVM Check local transaction status ( Transaction status check )
- According to the transaction status, it is determined to be Commit/Rollback( The second stage )
summary
Introduces the background of distributed transaction , And several basic solutions
Several basic solutions
Transaction compensation mechanism
This article gives the possible performance problems , It can be optimized in terms of fragmentation
Transaction message
Several additional frameworks
- rocketMQ
- seata
边栏推荐
- About%*s and%* s
- Usage of pure virtual functions
- QT database connection deletion
- Basic syntax and common commands of R language
- Agent and classloader
- User defined data type - structure
- Installing QT plug-in in Visual Studio
- SPARQL learning notes of query, an rrdf query language
- Solution of push code failure in idea
- @Font face fonts only work on their own domain - @font-face fonts only work on their own domain
猜你喜欢
![[paper notes] street view change detection with deconvolutional networks](/img/2d/777fd0d85ff4d349516b95923410fd.jpg)
[paper notes] street view change detection with deconvolutional networks

Js- get the mouse coordinates and follow them

Stack and queue

Some usage records about using pyqt5

System Verilog - thread

(1) Introduction

Using R language in jupyter notebook

QT set process startup and self startup

Graphic control and layout basis of R visualization

Data preprocessing - normalization and standardization
随机推荐
Dynamic memory allocation
Iterator failure condition
Two advanced playing methods of QT signal and slot
Sampling method and descriptive statistical function in R language
Why should the coroutine be set to non blocking IO
Record the time to read the file (the system cannot find the specified path)
Agent and classloader
About%*s and%* s
Afterword of Parl intensive learning 7-day punch in camp
JS capture, target, bubble phase
QT loading third-party library basic operation
[paper notes] poly yolo: higher speed, more precise detection and instance segmentation for yolov3
Using Visual Studio
User defined data type - structure
QT excel table read / write library - qtxlsx
Several solutions to the distributed lock problem in partial Internet companies
QT database connection
Is it safe to open an account for new bonds? What preparations are needed
The last glory of the late Ming Dynasty - the battle of Korea
[paper notes] mcunetv2: memory efficient patch based influence for tiny deep learning