Skip to content

Instantly share code, notes, and snippets.

@xialeistudio
Last active April 30, 2023 03:43
Show Gist options
  • Save xialeistudio/0c5a25af851bf3f209333475efc6ef25 to your computer and use it in GitHub Desktop.
Save xialeistudio/0c5a25af851bf3f209333475efc6ef25 to your computer and use it in GitHub Desktop.
Procedure of Mysql Transaction

Example

An example of A transfer 10 yuan to B.

Before transaction

  • A: 10
  • B: 10
sequenceDiagram

autonumber
participant E as Excute Engine

E -->>+ Disk: Read data of A;
Disk -->>- E: data of A;

E -->>+ UndoLog: Write and flush Undolog of A;
UndoLog -->>- E: Undolog flushed;

E -->>+ Bufferpool: Modify A to 0;
Bufferpool -->>-E: Modified;

E -->>+ RedoLog: Write RedoLog buffer of A;
RedoLog -->>-E: RedoLog written;

E -->>+ Disk: Read data of B;
Disk -->>-E: data of B;

E -->>+ UndoLog: Write and flush Undolog of B;
UndoLog -->>-E: Undolog flushed;

E -->>+ Bufferpool: Modify B to 20;
Bufferpool -->>-E: Modified;

E -->>+ RedoLog: Write RedoLog buffer of B;
RedoLog -->>-E: RedoLog written;

E -->>+ RedoLog: Prepare commit;
RedoLog -->>-E: Prepared;

E -->>+ Bufferpool: Prepare commit;
Bufferpool -->>-E: Prepared;

E -->>+Binlog: Write and flush binlog;
Binlog -->>-E: Binlog flushed;

E -->>+Bufferpool: Flush data;
Bufferpool -->>-E: flushed;

E -->>+UndoLog: Flush data;
UndoLog -->>-E: flushed;

E -->>+ RedoLog: Commit;
RedoLog -->>-E: Commited;
Loading

QA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment