the exciting mysql 5.7 replication enhancements › presentations › innovation-day...interesting...

67
Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US The Exciting MySQL 5.7 Replication Enhancements Luís Soares ([email protected]) Principal Software Engineer, MySQL Replication Team Lead 1

Upload: others

Post on 23-Jun-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US

The Exciting MySQL 5.7 Replication Enhancements

Luís Soares ([email protected])Principal Software Engineer, MySQL Replication Team Lead

1

Page 2: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Safe Harbor Statement

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 2

Page 3: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 4: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Program Agenda

Background

MySQL 5.7 Replication Generally Available

The New Replication Features in MySQL 5.7

Development Sneak Peek

Roadmap

Summary

1

2

3

4

5

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 4

6

Page 5: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

MySQL 5.7 Replication Generally Available1

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 6: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Interesting Stats Related to MySQL 5.7

• 40 replication worklogs pushed to MySQL 5.7

– 29 related to on MySQL replication Core

– 11 are ground work for MySQL Group Replication.

• 8 contributions merged into MySQL 5.7.

• 19 major enhancements to the replication core.

• 14 refactoring and modularization related changes to the code.

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 6

Page 7: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Background2

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 8: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Background: Replication Components

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 8

Page 9: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Background: Replication Components

• Binary Log

– File based logical log that records the changes on the master.

– Statement or Row based format (may be intermixed).

– Each transaction is split into groups of events.

– Control events: Rotate, Format Description, Gtid, ...

Monday, April 25, 2016

Layout of a Binary Log File

BEGIN ...E1 E2 COMMIT BEGIN ...E1 E2 COMMIT

MySQL Innovation Day 2016 - Redwood Shores, California, US 9

Page 10: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

M S

S

S

S

M

write clients read clientsread clients

write clients

Morereads?More

slaves!

Read scale-out

Background: What is Replication Used For?

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 10

Page 11: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

C

B

A

C

B

ACrash

C

B

A

B is thenew master

Uh Oh! Whew!

Redundancy: If master crashes, promote slave to master

Background: What is Replication Used For?

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 11

Page 12: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

M

S

write clients

business intelligent client applicationsreporting client applicationsbig queries client applications

On-line Backup and Reporting

Background: What is Replication Used For?

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 12

Page 13: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

CB

BAAC

Image fromwww.ginkgomaps.com

Background: What is Replication Used For?

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 13

Page 14: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

The New Replication Features in MySQL 5.73

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 15: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

The New Replication Features in MySQL 5.7Usability / Online

3

Monday, April 25, 2016

3.1

MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 16: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Online Reconfiguration of Global Transaction Identifiers

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 16

Page 17: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Online Reconfiguration of Global Transaction Identifiers

• The procedure is online.

– Both reads and writes are allowed while global transaction identifiers are being turned on or off in the entire replication cluster.

• No need to synchronize servers, ever.

• No need to restart servers.

• No need to change replication topology.

–Works in arbitrary topologies.

• Should anything happen in the middle of the procedure, you can always roll back.

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 17

Page 18: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Online Reconfiguration of Global Transaction Identifiers

• Over simplified procedure to turn on global transaction identifiers:

• Details: http://dev.mysql.com/doc/refman/5.7/en/replication-mode-change-online-enable-gtids.html

Monday, April 25, 2016

1) SET @@GLOBAL.GTID_MODE = OFF_PERMISSIVE; (on every server)2) SET @@GLOBAL.GTID_MODE = ON_PERMISSIVE; (on every server)3) wait for a bit longer than your replication lag4) SET @@GLOBAL.GTID_MODE = ON; (on every server)

MySQL Innovation Day 2016 - Redwood Shores, California, US 18

Page 19: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Online Reconfiguration of Replication Filters

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 19

Page 20: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Online Reconfiguration of Replication Filters

• Change Slave's Replication Filters dynamically.

– No need to stop and restart the slave server for setting new replication filtering rules.

– All slave filters are supported.

– Values can be input in various character sets.

Monday, April 25, 2016

mysql> CHANGE REPLICATION FILTER REPLICATE_DO_DB= (db1, db2)

MySQL Innovation Day 2016 - Redwood Shores, California, US 20

Page 21: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Online Reconfiguration of Replication Receiver/Applier

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 21

Page 22: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Change master from A to B without stopping the applier threads.

Online Reconfiguration of Replication Receiver/Applier

Monday, April 25, 2016

C

B

A

C

B

ACrash

C

B

A

B is thenew master

Uh Oh! Whew!

MySQL Innovation Day 2016 - Redwood Shores, California, US 22

Page 23: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Change master from A to B without stopping the applier threads.

Online Reconfiguration of Replication Receiver/Applier

Monday, April 25, 2016

C

B

A

C

B

ACrash

C

B

AUh Oh! Whew!

DBA did not need C to stop applying its relay log to change C's master from A to B.

MySQL Innovation Day 2016 - Redwood Shores, California, US 23

Page 24: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Online Reconfiguration of Replication Receiver/Applier

• Enables more online operations during fail-over:

• Stopping, changing master and restarting the receiver thread are all done while the applier thread is running.

• Change applier properties while the receiver thread is working:

Monday, April 25, 2016

mysql> STOP SLAVE IO_THREAD;

mysql> CHANGE MASTER TO MASTER_HOST='master2', …;

mysql> START SLAVE IO_THREAD;

mysql> STOP SLAVE SQL_THREAD;

mysql> CHANGE MASTER TO MASTER_DELAY=3600, …;

mysql> START SLAVE SQL_THREAD;

MySQL Innovation Day 2016 - Redwood Shores, California, US 24

Page 25: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved Replication Monitoring

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 25

DBA

Page 26: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved Replication Monitoring

• Monitoring through SQL.

• Grouping logically related information.

• Extensible, can be adapted to new features.

• More accurate and consistent identifier names.

• Master-slave, Multi-source, Group Replication support.

Performance Schema Replication Tables

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 26

Page 27: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved Replication Monitoring

Monday, April 25, 2016

Connection Configuration

Connection Status

Applier Configuration

ApplierStatus

(Slave) Receiver and Applier Status

Applier / CoordinatorStatus

WorkersStatus

MySQL Innovation Day 2016 - Redwood Shores, California, US 27

Page 28: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved Replication Monitoring

Monday, April 25, 2016

mysql> select * from performance_schema.replication_applier_status_by_worker\G

*************************** 1. row ***************************

CHANNEL_NAME:

WORKER_ID: 1

THREAD_ID: 35

SERVICE_STATE: ON

LAST_SEEN_TRANSACTION: 4ba0eb86-63c3-11e4-92ba-28b2bd168d07:2368

LAST_ERROR_NUMBER: 0

LAST_ERROR_MESSAGE:

LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00

*************************** 2. row ***************************

CHANNEL_NAME:

WORKER_ID: 2

THREAD_ID: 36

SERVICE_STATE: ON

LAST_SEEN_TRANSACTION: 4ba0eb86-63c3-11e4-92ba-28b2bd168d07:2367

LAST_ERROR_NUMBER: 0

LAST_ERROR_MESSAGE:

LAST_ERROR_TIMESTAMP: 0000-00-00 00:00:00

2 rows in set (0,00 sec)

MySQL Innovation Day 2016 - Redwood Shores, California, US 28

Page 29: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

The New Replication Features in MySQL 5.7Usability / Online

Performance

3

Monday, April 25, 2016

3.1

3.2

MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 30: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved Applier Throughput – Locking-based Parallelism

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 30

Page 31: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved Applier Throughput – Locking-based Parallelism

Monday, April 25, 2016

Single Threaded Apply 8 Threads Applier 24 Threads Applier 48 Threads Applier 96 Threads Applier

0%

50%

100%

150%

200%

250%

Fast and Scalable Multi-threaded Replication Applier

(statement-based replication, durable settings, SSD storage)

Sla

ve a

pply

tim

e (

Sysbench R

W o

n t

he m

aste

r w

ith 9

6 t

hre

ads =

100%

)

10X

MySQL Innovation Day 2016 - Redwood Shores, California, US 31

Page 32: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved Applier Throughput – Locking-based Parallelism

• Leverage parallelization information from master execution:

– Concurrent transactions, which have not blocked each other on the master, are marked as non-contending in the binary log.

• Meanwhile, at the slave:

–Non-contending transactions are scheduled in parallel;

– Concurrent transactions commit independently, thus no waiting involved.

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 32

Page 33: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved Applier Throughput – Locking-based Parallelism

• T2 is scheduled to execute together with T1.

• T3 is scheduled to execute as soon as T1 finishes.

Monday, April 25, 2016

T1

T2

T3

Time

Commit Finishes

Last Lock Acquired

Concurrent Execution Historyon the Master

Execution

Commit

T1 and T2 execute inparallel on the slave.

T2 and T3 execute in parallel on the slave.

MySQL Innovation Day 2016 - Redwood Shores, California, US 33

Page 34: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved Applier Throughput – Locking-based Parallelism

• Supports statement-based or row-based formats.

• Scheduling policy controlled through:

– logical_clock - means schedule based on the locking interval timestamps.

– database - the scheduling policy from 5.6 (concurrency control done per database).

• Work to improve slave scalability continues, does not stop here.

Monday, April 25, 2016

mysql> SET slave_parallel_type= [logical_clock|database]

MySQL Innovation Day 2016 - Redwood Shores, California, US 34

Page 35: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved User Threads-Sender Threads Synchronization

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 35

Page 36: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Improved User Threads-Sender Threads Synchronization

• Concurrent reads by the sender thread with ongoing writes from user threads.

– Sender thread does not block user sessions more than necessary.

– Higher throughput for both sender threads and user sessions.

Monday, April 25, 2016

Sender Thread Reads Binary Log User Thread Writes to Binary Log

Sender Thread Reads Binary Log

User Thread Writes to Binary Log

pre 5.7.2

5.7.2+

MySQL Innovation Day 2016 - Redwood Shores, California, US 36

Page 37: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Faster Sender Thread

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 37

Page 38: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Faster Sender Thread

Monday, April 25, 2016

• Send buffer is not allocated and freed every time an event is sent.

• When sender threads require larger send buffer - buffer grows as needed.

• When buffer is larger than needed - buffer shrinks dynamically.

• Together with the sender thread enhancements released on MySQL 5.7.2:

– increases master scalability;

– reduces resource consumption (CPU);

–Master, with dump threads attached, copes better with peak loads.

MySQL Innovation Day 2016 - Redwood Shores, California, US 38

Page 39: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Faster Sender Thread

• Ad hoc microbenchmark using mysqlslap

• 1M queries, concurrency=200, commit=1

• N slaves attached (fake slaves using remote mysqlbinlogs)

• 48 cores HT / 512 GB RAM / HDD

Monday, April 25, 2016

0

2000

4000

6000

8000

10000

12000

14000

16000

0 1 5 10 20 30 40 50 100

Qp

S

Number of Connected Sender Threads

Master’s Throughput

MySQL 5.6.16 MySQL 5.7.4

MySQL Innovation Day 2016 - Redwood Shores, California, US 39

Page 40: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Faster Semi-sync Replication – ACK Receiver Thread

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

ACKReceiverthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

Senderthread

MySQL Innovation Day 2016 - Redwood Shores, California, US 40

Page 41: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Faster Semi-sync Replication – ACK Receiver Thread

• Consecutive transactions do not block each other while waiting for ACKs

– Transaction t1 and t2 are sent immediately to the slave by the sender thread

– ACKs are received only by a special thread

– Transaction t2 does not include t1 round trip in its semi-sync overall latency

• Thread starts when semi-sync is activated

• Thread stops when semi-sync is deactivated

Monday, April 25, 2016

mysql> SET GLOBAL rpl_semi_sync_master_enabled= ON

mysql> SET GLOBAL rpl_semi_sync_master_enabled= OFF

MySQL Innovation Day 2016 - Redwood Shores, California, US 41

Page 42: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Faster Semi-sync: Durability over the Network

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 42

Orange bar percentage shows the throughput gain (orange) when compared to the corresponding blue bar. Blue and stacked bars show throughput ratio computed against the best blue bar.

Page 43: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

The New Replication Features in MySQL 5.7Usability / Online

Performance

Dependability

3

Monday, April 25, 2016

3.1

3.2

3.3

MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 44: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Loss-less Semi-sync Replication

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 44

Page 45: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Loss-less Semi-sync Replication

Monday, April 25, 2016

Master

Slave

T1: INSERT INTO t1 VALUES (1000)

ACK

Time

T2: SELECT * FROM t1; empty set

execute prepare binlog

relay log

commitexecute

MySQL Innovation Day 2016 - Redwood Shores, California, US 45

Page 46: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Loss-less Semi-sync Replication

• Master waits for slave's ACK before committing (as opposed to: master waits for slave's ACK after committing).

– Therefore, concurrent transactions do not see changes while this transaction waits for ack.

• Should a master fail, then any transaction that it may have externalized is also persisted on a slave.

• User can choose between the original semi-sync behavior and the new one.

Monday, April 25, 2016

mysql> SET rpl_semi_sync_master_wait_point= [AFTER_SYNC|AFTER_COMMIT]

MySQL Innovation Day 2016 - Redwood Shores, California, US 46

Page 47: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Semi-sync Replication – Wait for Multiple ACKs

Monday, April 25, 2016

Insert...

Insert...

B

binary log

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 47

Page 48: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Semi-sync Replication – Wait for Multiple ACKs

• Master does not commit transaction until it receives N ACKs from N slaves.

• Dynamically settable:

Monday, April 25, 2016

mysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= N

MySQL Innovation Day 2016 - Redwood Shores, California, US 48

Page 49: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Semi-sync Replication – Wait for Multiple ACKs

• Master does not commit transaction until it receives N ACKs from N slaves.

• Dynamically settable:

Monday, April 25, 2016

mysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= N

Master

Slave 2

T1: COMMIT

ACK

Slave 1ACK

T1: COMMITsucceeds

mysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= 2

Slave 3

Time

relay log

relay log

relay log

MySQL Innovation Day 2016 - Redwood Shores, California, US 49

ACK

Page 50: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

The New Replication Features in MySQL 5.7Usability / Online

Performance

Dependability

Flexibility

3

Monday, April 25, 2016

3.1

3.2

3.3

3.4

MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 51: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Storing Global Transaction Identifiers in a Table

Monday, April 25, 2016

Insert...

B

Insert...

relay log

Insert...

A

binary log

Client

Senderthread

Receiverthread

ApplierThreads

ReceiverMeta-data

Update

ApplierMeta-data

Update

Network

MySQL Innovation Day 2016 - Redwood Shores, California, US 51

Page 52: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Storing Global Transaction Identifiers in a Table

• Slaves can use GTIDs with binary logs disabled.

– Slaves that are never candidates to become a master can still use GTIDs for auto positioning.

Use Cases

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 52

Page 53: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Storing Global Transaction Identifiers in a Table

• GTIDs are saved into a mysql system table (range-compressed).

• GTIDs are inserted into the table as transactions commit.

• A compression thread runs periodically and compresses the table into ranges.

– New global variable controls the period: gtid_executed_compression_period.

Mechanics

Monday, April 25, 2016

CREATE TABLE gtid_executed(

source_uuid CHAR(36) NOT NULL,

interval_start BIGINT NOT NULL,

interval_end BIGINT NOT NULL,

PRIMARY KEY(source_uuid, interval_start)

);

mysql> SET GLOBAL gtid_executed_compression_period= N;(N – number of transactions)

MySQL Innovation Day 2016 - Redwood Shores, California, US 53

Page 54: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Storing Global Transaction Identifiers in a Table

• Binary Log Enabled

– Store GTID in binary log (transactionally).

– Copy GTID set to table on binary log rotation.

• Binary Log Disabled– Store GTID in table (transactionally).

– New transactions do not get an automatic GTID assigned.

• Always store GTIDs transactionally.

Mechanics

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 54

Page 55: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Multi-Source Replication

Monday, April 25, 2016

S

M M Slave can have more than one master.M M

The need for gathering data in a central server:• Integrated backup;• Complex queries for analytics purposes;• Data HUB for inter-cluster replication.

MySQL Innovation Day 2016 - Redwood Shores, California, US 55

Page 56: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Multi-Source Replication• A server (slave) can replicate from multiple sources (masters).

• Multiple channels (channel: receiver thread, relay logs, applier threads) that can be stopped started individually.

• Integrated with Multi-threaded Slave (each channel has its own multi-threaded applier set of threads).

• Integrated with the new P_S tables.

– replication_applier_status_by_coordinator shows multiple entries, one per channel/source coordinator.

– replication_applier_status_by_worker shows multiple entries, multiple entries per channel

– replication_connection_status shows multiple entries, one per connection to different sources.

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 56

Page 57: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Multi-Source Replication

• Integrated with GTIDs.

• Integrated with crash-safe tables.

– Progress state is stored in these tables for recoverability purposes.

• Virtually no limit on the number of sources (capped to 256, but can be changed if server binary is rebuilt).

• Able to manage each source separately.

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 57

Page 58: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

The New Replication Features in MySQL 5.7Usability / Online

Performance

Dependability

Flexibility

Misc

3

Monday, April 25, 2016

3.1

3.2

3.3

3.4

3.5

MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 59: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

“Smaller”, yet interesting, enhancements!• Multi-threaded applier is able to retry failed transactions.

• Option to make the Multi-threaded applier preserve commit order.

• SSL options for mysqlbinlog tool.

• Rewrite DB rules for the mysqlbinlog tool.

• Function to wait for transactions to be applied, regardless of the replication stream they come from.

• Options to track global transaction identifiers in the return packet of the mysqlprotocol. Useful for tracking GTID session state and enabler for session consistency.

• Support for XA transactions when the binary log is enabled.

• Change in the defaults. E.g., binlog_format=ROW and sync_binlog=1.

• Options to fine tune the binary log group commit procedure.

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 59

Page 60: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Development Sneak Peek4

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 61: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

MySQL Group Replication Plugin

Monday, April 25, 2016

M M M M M

Replication Group

• Multi-master update everywhere

• Automatic group membership management and failure detection.

• No need for server fail-over.

• Automatic reconfiguration.

• No single point of failure.

• Shared-nothing state machine replication.

• InnoDB compliant. Off-the-shelf hardware friendly.

MySQL Innovation Day 2016 - Redwood Shores, California, US 61

Page 62: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Roadmap5

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 63: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

What is Next?

• MySQL Group Replication

– Rapid releases.

– Improve performance, stability and usability.

• MySQL Replication Usability– Instrument even more replication and extend replication P_S tables

– Simpler administrative commands, more online operations

• MySQL Replication Performance– Continue to improve replication stream multi-threaded (slave) applier

– Continue to improve replication stream pipeline performance and efficiency

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 63

Page 64: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Summary6

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US

Page 65: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Summary

• Replication feature set in MySQL 5.7 shows many improvements:

– Semi-sync is more flexible and faster.

– Less contention on the binary log.

– Slave is faster and provides an inter-transaction parallelization scheme.

–More online reconfiguration: Global Transaction Identifiers, filters, configuration.

– Improved monitoring.

– Even more flexible replication with multi-source enabling new deployment scenarios.

– Enhancements all over: transaction retries, sequential commits, XA support, new replication functions, security.

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 65

Page 66: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related

Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |

Where to go from here?

• Packages

– http://dev.mysql.com

– http://labs.mysql.com

• Reference Documentation– http://dev.mysql.com/doc/refman/5.7/en/replication.html

• Blogs from the Engineers (news, quirks, technical information and much more)

– http://mysqlhighavailability.com

Monday, April 25, 2016 MySQL Innovation Day 2016 - Redwood Shores, California, US 66

Page 67: The Exciting MySQL 5.7 Replication Enhancements › presentations › innovation-day...Interesting Stats Related to MySQL 5.7 •40 replication worklogs pushed to MySQL 5.7 –29 related