04 Transaction Replication
04 Transaction Replication
Lê Hồng Hải
UET-VNUH
Overview
1 Introduction
2 Commit-Rollback
3 Isolation Levels
4 Deadlock
2
Transaction example
3
Transaction example
4
Transaction
5
Transaction-Commit-Rollback
6
Script that performs the above steps:
-- 1. start a new transaction
START TRANSACTION;
-- 2. Get the latest order number
SELECT
@orderNumber:=MAX(orderNUmber)+1
FROM
orders;
-- 3. insert a new order for customer 145
INSERT INTO orders(orderNumber,
orderDate,
requiredDate,
shippedDate,
status,
customerNumber)
VALUES(@orderNumber,
'2005-05-31',
'2005-06-10',
'2005-06-11',
'In Process',
145);
7
Script that performs the above steps (ctn..)
-- 5. commit changes
COMMIT;
8
More on Transaction
9
Transaction Savepoint
10
MySQL Transaction
11
Transaction Properties
https://www.ibm.com/docs/en/cics-
ts/5.4?topic=processing-acid-properties-
transactions
12
Transaction in programming languages
http://www.mysqltutorial.org/mysql-
transaction.aspx
http://www.mysqltutorial.org/mysql-jdbc-
transaction/
13
Transaction in Distributed System
14
Today’s Overview
1 Introduction
2 Commit-Rollback
3 Isolation Levels
4 MVCC
15
Transaction isolation levels
16
Dirty Reads
17
Nonrepeatable read
18
Phantom Reads
19
MySQL Isolation Levels
Nonrepea
Dirty Phantom
Isolation Levels Usage table
reads reads
reads
20
Choose Isolation Level
21
Setting Isolation level in MySQL
22
Multi-versioned concurrency control (MVCC)
http://en.wikipedia.org/wiki/Multiversion_concurrency_
control
23
Overview
1 Introduction
2 Commit-Rollback
3 Isolation Levels
4 Deadlock
24
Deadlock i
25
Deadlock
26
Non Transactional engine (MyISAM)
27
REPLICATION
Database Replication
29
Database Replication
30
Replication Advantages
31
Asynchronous Replication in MySQL
32
LOG Formats
33
MySQL Asynchronous Replication
34
Config Slave server
35
Config Slave server
◼ START SLAVE;
◼ SHOW SLAVE STATUS
36
MySQL Semisynchronous Replication
37
Semisynchronous Replication
38
MySQL Group Replication
39
Some Multi-Master solutions for MySQL
40
THANKS YOU