当前位置:网站首页>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
边栏推荐
- QT source code online view
- Single user mode
- QT set process startup and self startup
- How to package rpm
- Learning C language today is the first time to learn C language. In college, C linguistics is not good, but I want to make progress, so I found a beep video on the Internet to learn C language
- Learning notes on February 18, 2022 (C language)
- semget No space left on device
- Record the time to read the file (the system cannot find the specified path)
- Shared memory synchronous encapsulation
- JS capture, target, bubble phase
猜你喜欢

Judging the number of leap years from 1 to N years

Data preprocessing - normalization and standardization

Learning notes on February 18, 2022 (C language)

JSON module dictionary and string conversion

Character encoding minutes

Js- get the mouse coordinates and follow them

Custom structure type

google_ Breakpad crash detection

Record the time to read the file (the system cannot find the specified path)

semget No space left on device
随机推荐
Luogu p5707 [deep foundation 2. example 12] late for school
Install Kali extension 1: (kali resolution problem)
[paper notes] overview of case segmentation
RDB and AOF persistence of redis
Mining procedure processing
Study notes of cmake
How to deal with mining process
Semaphore function
Disable scrolling in the iPhone web app- Disable scrolling in an iPhone web application?
Fishing detection software
Cross compilation correlation of curl Library
[paper notes] poly yolo: higher speed, more precise detection and instance segmentation for yolov3
Two advanced playing methods of QT signal and slot
If a thread overflows heap memory or stack memory, will other threads continue to work
google_ Breakpad crash detection
QT database connection
@Font face fonts only work on their own domain - @font-face fonts only work on their own domain
iconv_ Open returns error code 22
JS capture, target, bubble phase
Modal and modeless dialogs for QT