mysql replication: what's new in mysql 5.7 and mysql 8 › ... › mysql8_replication.pdf ·...

56
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. MySQL Replication: What's New In MySQL 5.7 and MySQL 8 Luís Soares Software Development Director MySQL Replication Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day 1

Upload: others

Post on 23-Jun-2020

31 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

MySQL Replication: What's New In MySQL 5.7 and MySQL 8

Luís SoaresSoftware Development DirectorMySQL Replication

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day 1

Page 2: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

Copyright © 2018, 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.

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day 2

Page 3: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Program Agenda

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day 3

Page 4: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Introduction

Use Cases

Enhancements in MySQL 8 (and 5.7)

Enhancements in lab.mysql.com

Roadmap

Conclusion

Program Agenda

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

1

2

3

4

4

5

6

Page 5: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Introduction

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

1

5

Page 6: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Boom

Web ExplodesFriday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Page 7: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Today...

– Technology mesh.

– All things distributed.

– Large amounts of data to handle, transform, store.

– Offline periods are horribly expensive, simply unaffordable.

– Go green requires dynamic and adaptative behavior.

– Much more data to store – e.g. social media, “Look at all of my pictures!”; Monitoring – Keeping logs for N years! ; IoT – and much more.

– Moving, transforming and processing data quicker than anyone else means having an edge over competitors.

– It is a zoo. Distributed coordination and monitoring is key.

7MySQL Innovation DayFriday, 27th April 2018, Redwood Shores, CA, USA

Page 8: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Database Replication

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

ServerB

ServerA

App

INSERT ...

INSERT ... INSERT ...

Replication“The process of generating and reproducing multiple copies of data at one or more sites.”,Database Systems: A Practical Approach to Design, Implementation, and Management, Thomas M. Connolly, Carolyn E. Begg, Third Edition, 2002.

8

Page 9: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

MySQL Database Replication: Overview

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

INSERT ...Server

B

binary log

INSERT ...

relay log

INSERT ...Server

A

binary log

App

ReceiverMeta-data

Update

ApplierMeta-data

Update

INSERT ...

Comm. Framework

9

Page 10: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

MySQL Database Replication: Overview

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

INSERT ...Server

B

binary log

INSERT ...

relay log

INSERT ...Server

A

binary log

App

ReceiverMeta-data

Update

ApplierMeta-data

Update

INSERT ...

Persistent

log buffer Threadedapplier

Send, Receive,ACK, NACK,

Heartbeating,...

Comm. Framework

Capturestatements

or datachanges.

Persistentlog buffer

10

Page 11: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

MySQL Database Replication: Some Notes

• Logical replication log recording master changes (binary log).

• Row or statement based format (may be intermixed).

• Each transaction is split into groups of events.

• Control events: Rotate, Format Description, Gtid, and more.

Binary Log

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Layout of the Binary Log.

BEGIN ...E1 E2 COMMIT BEGIN ...E1 E2 COMMITGTID GTID

11

Page 12: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Coordination Between Servers

MySQL Database Replication: Some Notes

12Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

A B Since 3.23

A B

semi-synchronous (plugin)

A CB

group replication (plugin)

transactions

transactions

Since 5.5

Since 5.7.17

asynchronous (native)

transactions, membership, coordination

acks

And in MySQL 8 as of 8.0.1

Page 13: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Use cases

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

2

13

Page 14: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Clustering Made Practical

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

RAISE

eplicate

utomate

ntegrate

cale

nhance

14

Page 15: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Replicate

• For highly available infrastructures where:

– the number of servers has to grow or shrink dynamically;

– with as little pain as possible.

Group Replication

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

A B C D E

15

Page 16: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Automate

• Single-primary mode

– Automatic PRIMARY/SECONDARY role assignment

– Automatic new PRIMARY election on PRIMARY failures

– Automatic setup of read/write modes on PRIMARY and SECONDARIES

– Automatic global consistent view of which server is the PRIMARY

Group Replication

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

S S S* S P S

Next PrimaryOld Primary

16

Page 17: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

IntegrateBinary Log

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

• Logical replication log

– Extract, transform and load.

– MySQL fits nicely with other technologies.

INSERT ...Server

A

Replication log

App

INSERT ...

Hadoop

Kafka

Solr

Lucene

...

Transform

17

Page 18: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Scale

• Replicate between clusters

– For disaster recovery

• Read Replicas

– For read-scale out. Deploy asynchronous read replicas connected to the cluster

Asynchronous Replication

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

A B C

J K L

D

I

M

Z

.

.

.

.

.

.

18

Page 19: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

InnoDB Cluster

Enhance

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

S1 S2 S3 S4 S…

M

M M

MySQL Connector

Application

MySQL Router

MySQL Connector

Application

MySQL Router

MySQL Shell

HA

Rep

licaS

et1

• InnoDB Cluster Integrated Solution

– Group Replication for high availability.

– Asynchronous Replication for Read Scale-out.

– One-stop shell to deploy and manage the cluster.

– Seamlessly and automatically route the workload to the proper database server in the cluster.

– Hide failures from the application.

19

Page 20: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Binary Log Metadata

Enhancements in MySQL 8 (and 5.7)

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

3.1

3

20

Operations3.2

Monitoring3.3

Performance3.4

Other3.5

Page 21: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

New Metadata in the Binary LogEasy to extract, transform and load into other systems.

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Gtid_log_eventTransaction length, …Commit timestamps

Table_map eventTypes, primary key, …Sign, charset, …

Write_rowsCommit

ServerA

Binary log

App

INSERT ...

21

• New Metadata

– Easy to decode what is in the binary log.

– Further facilitates connecting MySQL to other systems using the binary log stream.

– Capturing data changes through the binary log is simplified.

– Also more stats showing where the data is/was at a certain point in time.

Page 22: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Enhancements in MySQL 8 (and 5.7)

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Binary Log Metadata3.1

3

22

Operations3.2

Monitoring3.3

Performance3.4

Other3.5

Page 23: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Replicate, Filter, Aggregate, Query

Multi-Source Replication Filters

23Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

A

B

C

users

bio

groups

users

posts

comments

users bio groups posts comments

only users

Page 24: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Automatic protection against involuntarily tainting of offline replicas

Preventing Updates On Replicas that Leave the Cluster

24Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

B C

A

B CA

A joins a single primary cluster andit allows update operations priorto joining.

A becomes a secondary and isautomatically set to read only.

B C

A

A leaves the group and remainsread only until the DBA reverts.

Backported to 5.7.20

Page 25: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Choose next primary by assigning election weights to the candidates.

Primary Election Weights

25Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

B CAw=100 w=90w=50

B

CA

w=100

w=90w=50

CAw=90w=50

B is the primary.

B is not in the group anymore.C has higher weight than A.

C is elected the new primary.

Backported to 5.7.20

Page 26: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

AppsApps

New options to fine tune the cluster automatic flow control in 8.0.

Online and Automatic Cluster Performance Management

26Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

B CA B CA B CA

B is struggling to keepup.

B is struggling tokeep up.

A and C throttlethemselves automatically.

B is not struggling any more.System adjusted Itself.

B has a chance tocatch up.

Apps

Page 27: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Enhancements in MySQL 8 (and 5.7)

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Binary Log Metadata3.1

3

27

Operations3.2

Monitoring3.3

Performance3.4

Other3.6

Page 28: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Through the entire asynchronous topology

Monitor Lag With Microsecond Precision

28Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

A B C D

How much time does my data take to reachD coming from A?

Page 29: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

From the immediate master

Monitor Lag With Microsecond Precision

29Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

A B C D

How much time does my data originated inA takes to flow from B to C?

Page 30: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

For each stage of the replication applier process

Monitor Lag with Microsecond Precision

30Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

D

Data

Worker ThreadsRelay Log

CoordinatorThread

ReceiverThread

• Per Stage Timestamps

– User can monitor how much time it takes for a specific transaction to traverse the pipeline.

Page 31: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Version, Role and more

Global Group Stats Available on Every Server

31Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

A B C

A is primary.B, C are secondaries.A: 5.7.20B, C: 8.0.3

A is primary.B, C are secondaries.A: 5.7.20B, C: 8.0.3

A is primary.B, C are secondaries.A: 5.7.20B, C: 8.0.3

• Query one Replica, Get status of all

– Every replica reports group-wide information about roles and versions of the members of the group.

– Also available at any replica are group-wide status.

Page 32: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Enhancements in MySQL 8 (and 5.7)

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Binary Log Metadata3.1

3

32

Operations3.2

Monitoring3.3

Performance3.4

Other3.5

Page 33: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Write set parallelization

Highly Efficient Replication Applier

33Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

0

5000

10000

15000

20000

25000

30000

35000

40000

45000

50000

1 2 4 8 16 32 64 128 256

Up

dat

es/

seco

nd

Ap

plie

s o

n t

he

Re

plic

a

Number of Clients on the Master

Applier Throughput: Sysbench Update Index

COMMIT_ORDER WRITESET WRITESET_SESSION

Backported to 5.7.22

Page 34: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Highly Efficient Replication Applier

• WRITESET dependency tracking allows applying a single threaded workload in parallel.

– Delivers the best throughput of the three dependency trackers, at any concurrency level.

• WRITESET_SESSION in addition to writesets tracks sessions dependencies as well. Two transactions executed on the same session are always scheduled in execution order on replica servers.

• Fast Group Replication recovery – time to catch up.

Write set parallelization

34Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Backported to 5.7.22

Page 35: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Replica quickly online by using WRITESET

Fast Group Replication Recovery

35Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

0

1

2

3

4

5

6

7

8

9

10

Sysbench RW at 33% capacity(workload: 9K TPS on 64 threads)

Sysbench RW at 66% capacity(workload: 18K TPS on 64 threads)

Tim

e to

cac

th-u

p p

er t

ime

of

wo

rlo

ad m

issi

ng

(rat

io)

Group Replication Recovery Time: Sysbench Update Index (durable settings)

MySQL 5.7.20 MySQL 8.0.3

0

1

2

3

4

5

6

7

8

9

10

Sysbench RW at 33% capacity(workload: 4K TPS on 64 threads)

Sysbench RW at 66% capacity(workload: 8K TPS on 64 threads)

Tim

e to

cac

th-u

p p

er t

ime

of

wo

rlo

ad m

issi

ng

(rat

io)

Group Replication Recovery Time: Sysbench RW (durable settings)

MySQL 5.7.20 MySQL 8.0.3

Backported to 5.7.22

Page 36: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

More transactions per second while sustaining zero lag on any replica

High Cluster Throughput

36Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

8 16 32 64

Number of Clients on the Master

Asynchronous Replication Sustained Throughput(Sysbench Update Index, non-durable settings)

MySQL 5.7 MySQL 8.0.3

0

5000

10000

15000

20000

25000

30000

35000

40000

45000

8 16 32 64

Up

dat

es

pe

r se

con

d

Number of Clients on the Master

Asynchronous Replication Sustained Throughput(Sysbench Update Index, durable settings)

MySQL 5.7 MySQL 8.0.3

Page 37: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

High Cluster Throughput

– At lower thread count, the throughput of the system doubles in MySQL 8.0 compared to MySQL 5.7 on durable settings.

– At lower thread count, the throughput of the system more than doubles in MySQL 8.0 compared to MySQL 5.7 on non-durable settings.

More transactions per second while sustaining zero lag on any replica

37Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Page 38: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Replicate only changed fields of documents (Partial JSON Updates)

Efficient Replication of JSON Documents

38Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

0

10000

20000

30000

40000

50000

60000

Entire JSON Partial JSON

Byt

es p

er

tran

sact

ion

Binary Log Space Per Transaction

FULL MINIMAL

• Numbers are from a specially designed benchmark:• tables have 10 JSON fields,• each transaction modifies

around 10% of the data

Page 39: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

0.0

500.0

1000.0

1500.0

2000.0

2500.0

1 2 3 4

Tran

sact

ion

s p

er s

eco

nd

Throughput on the Master: Partial JSON vs Complete JSON

4 8 16 32 64

Replicate only fields of the document that changed (Partial JSON Updates)

Efficient Replication of JSON Documents

39Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

0

1000

2000

3000

4000

5000

6000

7000

8000

9000

Throughput on the Slave: Partial JSON vs Ccomplete JSON

4 8 16 32 64

FULL MINIMAL FULL MINIMAL FULL MINIMAL FULL MINIMAL

COMPLETE JSON PARTIAL JSON COMPLETE JSON PARTIAL JSON

Page 40: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Enhancements in MySQL 8 (and 5.7)

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Binary Log Metadata3.1

3

40

Operations3.2

Monitoring3.3

Performance3.4

Other3.5

Page 41: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Changes to defaults in MySQL 8

• Binary log is on by default.

• Logging of slave updates is on by default.

• Replication metadata is stored in InnoDB tables by default instead of files.

• Row-based applier uses hash scans to find rows instead of table scans.

• Transaction write-set extraction is on by default.

• Binary log expiration is set to 30 days by default.

• Server-id is set to 1 by default instead of 0.

High performance replication enabled out-of-the-box

41Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Page 42: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Other MySQL 8 Replication Enhancements

• Monitoring: Monitor replication even when disk full

• Monitoring: Current query being applied, even for row-based replication

• Monitoring: Replication filters statistics in performance schema

• Monitoring: Group Replication threads instrumented and shown in performance schema

• Monitoring: Group Replication conditional variables and mutexesinstrumented and shown in performance schema

• Recoverability: Recover DDL and binary log together after a crash

42Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Page 43: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Other MySQL 8 Replication Enhancements

• Operations: Restore global transaction identifiers metadata on a non-empty server

• Operations: Specify binary log file number after RESET MASTER

• Operations: Specify when binary log files are automatically purged (with second precision)

• Operations: SAVEPOINT support when write sets are being extracted

• Operations: P_S table for consistent log positions (replacing potentially expensive FLUSH TABLE WITH READ LOCKS)

• Operations: Support hostnames in Group Replication whitelist

43Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Backported to 5.7.19

Backported to 5.7.21

Page 44: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Other MySQL 8 Replication Enhancements

• Troubleshooting: Dynamic and high performance debugging of group replication inter-node messaging

44Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

Page 45: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Enhancements in Labs

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

4

45

Operations4.1

Monitoring4.2

Page 46: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Enhancements in Labs

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

4

46

Operations4.1

Monitoring4.2

Page 47: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Automatically Shutdown When Replica Leaves the Group Involuntarily

Automatic Abort Replicas that Leave the Group

47Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

B C

A

A shuts itself down, thus becomingeffectively unavailble for both readsand write operations.

B CA

A is a secondary and wasautomatically set to read only.

B C

A

A leaves the group involuntarily(failed to apply changes, networkpartitioned, etc).

http://labs.mysql.com

@@group_replication_exit_state_action={ READ_ONLY | ABORT_SERVER }

Page 48: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Enhancements in Labs

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

4

48

Operations4.1

Monitoring4.2

Page 49: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Group Replication Message Cache Memory Usage

• GCS/XCom’s Paxos message cache is instrumented.

• GCS/XCom’s Paxos message cache memory usage is exposed in performance schema.

49Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

-- This is a session open on ServerA and the user is reading stats on GCS_Xcom message cacheServerA> select * from memory_summary_global_by_event_name where event_namelike "%GCS_XCom%"\G*************************** 1. row ***************************

EVENT_NAME: memory/group_rpl/GCS_XCom::xcom_cacheCOUNT_ALLOC: 28890317COUNT_FREE: 28840318

SUM_NUMBER_OF_BYTES_ALLOC: 24499151783SUM_NUMBER_OF_BYTES_FREE: 24470424555

LOW_COUNT_USED: 0CURRENT_COUNT_USED: 49999

HIGH_COUNT_USED: 50000LOW_NUMBER_OF_BYTES_USED: 0

CURRENT_NUMBER_OF_BYTES_USED: 28727228HIGH_NUMBER_OF_BYTES_USED: 135676530

1 row in set (0.01 sec)

http://labs.mysql.com

Page 50: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Roadmap

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

5

50

Page 51: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

The Road to MySQL 8 Group Replication and InnoDB Clusters

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

MySQL 5.6.105.6 is GA

MySQL 5.7.95.7 is GAlifecycle interfacesP_S tables for GRserver side changes

GR 0.2.0 labsHello world!

MySQL 5.7.17GR is GA

...

MySQL 8.0.1 DMRGR is released with 8InnoDB Cluster is GALots of replication enhancements

MySQL 8.0.3 RC1bug fixespartial json updatesmonitoring enhancements

51

MySQL 8.0.4 RC2bug fixesmonitoring

MySQL 8.0.11 GAbug fixesMySQL 8.0.0 DMR

MySQL 8.0.2 DMRMore replicationenhancements

Page 52: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

MySQL InnoDB Cluster: The End Goal

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

S1 S2 S3 S4 S…

M

M M

MySQL Connector

Application

MySQL Router

MySQL Connector

Application

MySQL Router

MySQL Shell

HA

Rep

licaS

et1

S1 S2 S3 S4 S…

M

M M

MySQL Connector

Application

MySQL Router

HA

Rep

licaS

etN

52

...

Page 53: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Conclusion

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day

6

53

Page 54: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Conclusion

MySQL 8.0.11 GA is out:

• Performance/efficiency improvements

– Smaller recovery times, faster applier, reduced storage footprint.

• Replication instrumentation

– Enhanced lag monitoring, more introspection into Group Replication stats and threads

• Powerful Dev-Ops– Enhanced multi-source replication filters, controlled primary election and fine tunning

of flow control.

– Improved crash-recovery, new defaults, more flexible GTID handling.

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day 54

Page 55: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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

Where to go from here?

• Packages

– http://www.mysql.com/downloads/

• Documentation– https://dev.mysql.com/doc/refman/8.0/en/

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

– http://mysqlhighavailability.com

Friday, 27th April 2018, Redwood Shores, CA, USA MySQL Innovation Day 55

Page 56: MySQL Replication: What's New In MySQL 5.7 and MySQL 8 › ... › MySQL8_Replication.pdf · MySQL Database Replication: Some Notes •Logical replication log recording master changes

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