3 / 147 · MySQL 8.0 InnoDB Cluster is a very easy High Availability solution for MySQL Frédéric...

Post on 24-Jul-2020

1 views 1 download

Transcript of 3 / 147 · MySQL 8.0 InnoDB Cluster is a very easy High Availability solution for MySQL Frédéric...

3 / 147

MySQL HA so easy ? That's insane !

MySQL 8.0 InnoDB Cluster is a very easy High Availability solution forMySQL

Frédéric Descamps - MySQL Community Manager - Oracle

4 / 147

Save the date !

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

5 / 147

 

Safe Harbor StatementThe following is intended to outline our general product direction. It is intended forinformation purpose only, and may not be incorporated into any contract. It is not acommitment to deliver any material, code, or functionality, and should not be relied up inmaking purchasing decisions. The development, release and timing of any features orfunctionality described for Oracle´s product remains at the sole discretion of Oracle.

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

6 / 147

about me - http://about.me/lefred

Who am I ?

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

7 / 147

Frédéric Descamps@lefredMySQL EvangelistHacking MySQL since 3.23devops believerliving in Belgium 🇧🇪http://lefred.be

 

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

8 / 147

MySQL InnoDB Cluster: vision  "A single product - MySQL - with high availability and scaling features baked in;providing an integrated end-to-end solution that is easy to use."

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

9 / 147

MySQL InnoDB Cluster: vision  "A single product - MySQL - with high availability and scaling features baked in;providing an integrated end-to-end solution that is easy to use."

InnoDB

cluster

Ease-of-Use

Extreme Scale-Out

Out-of-Box Solution

Built-in HA

High Performance

Everything Integrated

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

10 / 147

One Product: MySQL

All components created togetherTested togetherPackaged together

Easy to Use

One client: MySQL ShellEasy packagingIntegrated orchestrationHomogenous servers

Flexible and Modern

SQL and NoSQL togetherProtocol BuffersAsynchronous APIDeveloper friendly

Support Read/Write Scale Out

Shared clustersFederated system of N replica sets

supporting cross shardoperations

Each replica set manages a shard

MySQL InnoDB Cluster: goals

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

11 / 147

MySQL InnoDB Cluster Architecture

A

p

p

l

i

c

a

t

i

o

n

M

y

S

Q

L

C

o

n

n

e

c

t

o

r

M

y

S

Q

L

R

o

u

t

e

r

M

y

S

Q

L

S

h

e

l

l

I

n

n

o

D

B

c

l

u

s

t

e

r

A

p

p

l

i

c

a

t

i

o

n

M

y

S

Q

L

C

o

n

n

e

c

t

o

r

M

y

S

Q

L

R

o

u

t

e

r

M

p

M

M

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

12 / 147

Let's start with the demo, shall we ?

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

13 / 147

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

14 / 147

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

15 / 147

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

16 / 147

Group Replication: heart of MySQL InnoDBCluster

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

17 / 147

Group Replication: heart of MySQL InnoDBCluster

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

18 / 147

MySQL Group Replication

but what is it ?!?

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

19 / 147

MySQL Group Replication

but what is it ?!?

GR is a plugin for MySQL, made by MySQL and packaged with MySQL

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

20 / 147

MySQL Group Replication

but what is it ?!?

GR is a plugin for MySQL, made by MySQL and packaged with MySQLGR is an implementation of Replicated Database State Machine theory

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

21 / 147

MySQL Group Replication

but what is it ?!?

GR is a plugin for MySQL, made by MySQL and packaged with MySQLGR is an implementation of Replicated Database State Machine theoryGR allows to write on all Group Members (cluster nodes) simultaneously whileretaining consistency

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

22 / 147

MySQL Group Replication

but what is it ?!?

GR is a plugin for MySQL, made by MySQL and packaged with MySQLGR is an implementation of Replicated Database State Machine theoryGR allows to write on all Group Members (cluster nodes) simultaneously whileretaining consistencyGR implements conflict detection and resolution

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

23 / 147

MySQL Group Replication

but what is it ?!?

GR is a plugin for MySQL, made by MySQL and packaged with MySQLGR is an implementation of Replicated Database State Machine theoryGR allows to write on all Group Members (cluster nodes) simultaneously whileretaining consistencyGR implements conflict detection and resolutionGR allows automatic distributed recovery

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

24 / 147

MySQL Group Replication

but what is it ?!?

GR is a plugin for MySQL, made by MySQL and packaged with MySQLGR is an implementation of Replicated Database State Machine theoryGR allows to write on all Group Members (cluster nodes) simultaneously whileretaining consistencyGR implements conflict detection and resolutionGR allows automatic distributed recoverySupported on all MySQL platforms !!

Linux, Windows, Solaris, OSX, FreeBSD

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

25 / 147

And what does it means for users ?

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

26 / 147

And what does it means for users ?no longer necessary to handle server fail-over manually or with a complicated script

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

27 / 147

And what does it means for users ?no longer necessary to handle server fail-over manually or with a complicated scriptGR provides fault tolerance

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

28 / 147

And what does it means for users ?no longer necessary to handle server fail-over manually or with a complicated scriptGR provides fault toleranceGR enables update-everywhere setups

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

29 / 147

And what does it means for users ?no longer necessary to handle server fail-over manually or with a complicated scriptGR provides fault toleranceGR enables update-everywhere setupsGR handles crashes, failures, re-connetcs automatically

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

30 / 147

And what does it means for users ?no longer necessary to handle server fail-over manually or with a complicated scriptGR provides fault toleranceGR enables update-everywhere setupsGR handles crashes, failures, re-connetcs automaticallyAllows an easy setup of a MySQL service high available !

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

31 / 147

Default = Single Primary ModeBy default, MySQL InnoDB Cluster runs in Single Primary Mode.

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

32 / 147

Default = Single Primary ModeBy default, MySQL InnoDB Cluster runs in Single Primary Mode.

mysql> show global variables like 'group_replication_single_primary_mode';+---------------------------------------+-------+| Variable_name | Value |+---------------------------------------+-------+| group_replication_single_primary_mode | ON |+---------------------------------------+-------+

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

33 / 147

Default = Single Primary ModeBy default, MySQL InnoDB Cluster runs in Single Primary Mode.

mysql> show global variables like 'group_replication_single_primary_mode';+---------------------------------------+-------+| Variable_name | Value |+---------------------------------------+-------+| group_replication_single_primary_mode | ON |+---------------------------------------+-------+

In Single Primary Mode, a single member acts as the writable master (PRIMARY) andthe rest of the members act as hot-standbys (SECONDARY).

The group itself coordinates and configures itself automatically to determine whichmember will act as the PRIMARY, through a leader election mechanism.

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

34 / 147

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

35 / 147

MySQL RouterMySQL Router is lightweight middleware that provides transparent routing between yourapplication and backend MySQL Servers. It can be used for a wide variety of use cases,such as providing high availability and scalability by effectively routing database trafficto appropriate backend MySQL Servers.

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

36 / 147

MySQL RouterMySQL Router is lightweight middleware that provides transparent routing between yourapplication and backend MySQL Servers. It can be used for a wide variety of use cases,such as providing high availability and scalability by effectively routing database trafficto appropriate backend MySQL Servers.

MySQL Router doesn´t require any specific configuration. It configures itselfautomatically (bootstrap) using MySQL InnoDB Cluster´s metadata.

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

37 / 147

ProxySQL has native support for GroupReplication which makes it a good choicefor advanced users.

ProxySQLIf you need some specific features that are not yet available in MySQL Router, liketransparent R/W splitting, then you can use your software of choice.

We are also collaborating with ProxySQL.

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

38 / 147

MySQL ShellThe MySQL Shell is an interactive Javascript, Python, or SQL interface supportingdevelopment and administration for the MySQL Server and is a component of the MySQLServer. You can use the MySQL Shell to perform data queries and updates as well asvarious administration operations.

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

39 / 147

MySQL Shell (2)The MySQL Shell provides:

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

40 / 147

MySQL Shell (2)The MySQL Shell provides:

Both Interactive and Batch operations

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

41 / 147

MySQL Shell (2)The MySQL Shell provides:

Both Interactive and Batch operationsDocument and Relational Models

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

42 / 147

MySQL Shell (2)The MySQL Shell provides:

Both Interactive and Batch operationsDocument and Relational ModelsCRUD Document and Relational APIs via scripting

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

43 / 147

MySQL Shell (2)The MySQL Shell provides:

Both Interactive and Batch operationsDocument and Relational ModelsCRUD Document and Relational APIs via scriptingTraditional Table, JSON, Tab Separated output results formats

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

44 / 147

MySQL Shell (2)The MySQL Shell provides:

Both Interactive and Batch operationsDocument and Relational ModelsCRUD Document and Relational APIs via scriptingTraditional Table, JSON, Tab Separated output results formatsMySQL Standard and X Protocols

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

45 / 147

MySQL Shell (2)The MySQL Shell provides:

Both Interactive and Batch operationsDocument and Relational ModelsCRUD Document and Relational APIs via scriptingTraditional Table, JSON, Tab Separated output results formatsMySQL Standard and X Protocolsand more...

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

46 / 147

New since MySQL 8.0.11The Shell improved a lot and uses all the enhancements part of MySQL 8:

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

47 / 147

New since MySQL 8.0.11The Shell improved a lot and uses all the enhancements part of MySQL 8:

set persists

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

48 / 147

New since MySQL 8.0.11The Shell improved a lot and uses all the enhancements part of MySQL 8:

set persists

restart

This makes the remote administration very easy and cloud friendly.

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

49 / 147

don´t forget, this is a HA solution !

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

50 / 147

Thank you !

Any Questions ?

share your 💕 for MySQL on social media using @MySQL #DataOpsBarcelona

more at http://lefred.be/content/category/mysql/group-replication/http://mysqlhighavailability.com/

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

51 / 147

want to know more?

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

52 / 147

GR is nice, but how does it work ?

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

53 / 147

GR is nice, but how does it work ?

it´s just ...

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

54 / 147

GR is nice, but how does it work ?

it´s just ...

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

55 / 147

GR is nice, but how does it work ?

it´s just ...

... no, in fact the writesets replication is synchronous and then certification and apply ofthe changes are local to each nodes and asynchronous.

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

56 / 147

GR is nice, but how does it work ?

it´s just ...

... no, in fact the writesets replication is synchronous and then certification and apply ofthe changes are local to each nodes and asynchronous.

not that easy to understand... right ? As a picture is worth a 1000 words, let´s illustratethis...

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

57 / 147

MySQL Group Replication

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

58 / 147

MySQL Group Replication

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

59 / 147

MySQL Group Replication

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

60 / 147

MySQL Group Replication

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

61 / 147

MySQL Group Replication

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

62 / 147

MySQL Group Replication

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

63 / 147

MySQL Group Replication

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

64 / 147

MySQL Group Replication

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

65 / 147

MySQL Group Replication

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

66 / 147

MySQL Group Replication

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

67 / 147

MySQL Group Replication

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

68 / 147

MySQL Group Replication

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

69 / 147

MySQL Group Replication (full transaction)

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

70 / 147

MySQL Group Replication (full transaction)

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

71 / 147

MySQL Group Replication (full transaction)

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

72 / 147

MySQL Group Replication (full transaction)

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

73 / 147

MySQL Group Replication (full transaction)

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

74 / 147

MySQL Group Replication (full transaction)

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

75 / 147

MySQL Group Replication (full transaction)

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

76 / 147

MySQL Group Replication (full transaction)

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

77 / 147

MySQL Group Replication (full transaction)

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

78 / 147

MySQL Group Communication System (GCS)MySQL Xcom protocol

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

79 / 147

MySQL Group Communication System (GCS)MySQL Xcom protocolReplicated Database State Machine

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

80 / 147

MySQL Group Communication System (GCS)MySQL Xcom protocolReplicated Database State MachinePaxos based protocol

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

81 / 147

MySQL Group Communication System (GCS)MySQL Xcom protocolReplicated Database State MachinePaxos based protocolits task: deliver messages across the distributed system:

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

82 / 147

MySQL Group Communication System (GCS)MySQL Xcom protocolReplicated Database State MachinePaxos based protocolits task: deliver messages across the distributed system:

atomically

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

83 / 147

MySQL Group Communication System (GCS)MySQL Xcom protocolReplicated Database State MachinePaxos based protocolits task: deliver messages across the distributed system:

atomicallyin Total Order

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

84 / 147

MySQL Group Communication System (GCS)MySQL Xcom protocolReplicated Database State MachinePaxos based protocolits task: deliver messages across the distributed system:

atomicallyin Total Order

MySQL Group Replication receives the Ordered 'tickets' from this GCS subsystem.

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

85 / 147

Group Replication : Total Order Delivery - GTID

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

86 / 147

Group Replication : Total Order Delivery - GTID

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

87 / 147

Group Replication : Total Order Delivery - GTID

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

88 / 147

Group Replication : Total Order Delivery - GTID

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

89 / 147

Group Replication : Total Order Delivery - GTID

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

90 / 147

Group Replication : Total Order Delivery - GTID

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

91 / 147

Group Replication : Total Order Delivery - GTID

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

92 / 147

Group Replication : Total Order Delivery - GTID

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

93 / 147

Group Replication : Total Order Delivery - GTID

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

94 / 147

Group Replication : Total Order Delivery - GTID

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

95 / 147

Group Replication : Total Order Delivery - GTID

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

96 / 147

Group Replication : Total Order Delivery - GTID

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

97 / 147

Group Replication : Total Order Delivery - GTID

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

98 / 147

Group Replication : Total Order Delivery - GTID

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

99 / 147

Group Replication : Total Order Delivery - GTID

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

100 / 147

Group Replication : Total Order Delivery - GTID

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

101 / 147

Group Replication : Total Order Delivery - GTID

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

102 / 147

Group Replication : Total Order Delivery - GTID

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

103 / 147

Group Replication : Total Order Delivery - GTID

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

104 / 147

Group Replication: return commitAsynchronous Replication:

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

105 / 147

Group Replication: return from commit (2)Semi-Sync Replication:

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

106 / 147

Group Replication: return from commit (3)Group Replication:

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

107 / 147

Does this mean we can have a distant node andalways let it ack later ?

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

108 / 147

Does this mean we can have a distant node andalways let it ack later ?

NO!

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

109 / 147

Does this mean we can have a distant node andalways let it ack later ?

NO!

There will be always a penalty to pay. For example if you have 3 members, every 3rd writethe system will be affected by the lartency... why ?

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

110 / 147

Does this mean we can have a distant node andalways let it ack later ?

NO!

There will be always a penalty to pay. For example if you have 3 members, every 3rd writethe system will be affected by the lartency... why ?

That´s because the system has to wait for the noop (single skip message) from the“distant” node.

More info: http://lefred.be/content/mysql-group-replication-about-ack-from-majority/

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

111 / 147

Group Replication : Optimistic LockingGroup Replication uses optimistic locking

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

112 / 147

Group Replication : Optimistic LockingGroup Replication uses optimistic locking

during a transaction, local (InnoDB) locking happens

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

113 / 147

Group Replication : Optimistic LockingGroup Replication uses optimistic locking

during a transaction, local (InnoDB) locking happensoptimistically assumes there will be no conflicts across nodes (no communication between nodes necessary)

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

114 / 147

Group Replication : Optimistic LockingGroup Replication uses optimistic locking

during a transaction, local (InnoDB) locking happensoptimistically assumes there will be no conflicts across nodes (no communication between nodes necessary)cluster-wide conflict resolution happens only at COMMIT, during certification

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

115 / 147

Group Replication : Optimistic LockingGroup Replication uses optimistic locking

during a transaction, local (InnoDB) locking happensoptimistically assumes there will be no conflicts across nodes (no communication between nodes necessary)cluster-wide conflict resolution happens only at COMMIT, during certification

Let´s first have a look at the traditional locking to compare.

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

116 / 147

Traditional locking

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

117 / 147

Traditional locking

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

118 / 147

Traditional locking

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

119 / 147

Traditional locking

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

120 / 147

Traditional locking

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

121 / 147

Traditional locking

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

122 / 147

Optimistic Locking

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

123 / 147

Optimistic Locking

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

124 / 147

Optimistic Locking

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

125 / 147

Optimistic Locking

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

126 / 147

Optimistic Locking

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

127 / 147

Optimistic Locking

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

128 / 147

Optimistic Locking

The system returns error 149 as certification failed:

ERROR 1180 (HY000): Got error 149 during COMMIT

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

129 / 147

Such conflicts happen only when using multi-primary group !

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

130 / 147

CertificationCertification is the process that only needs to answer the following unique question:

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

131 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?

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

132 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?based on unapplied earlier transactions

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

133 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?based on unapplied earlier transactionssuch conflicts must come for other members/nodes

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

134 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?based on unapplied earlier transactionssuch conflicts must come for other members/nodes

happens on every member/node

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

135 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?based on unapplied earlier transactionssuch conflicts must come for other members/nodes

happens on every member/nodeshould be deterministic on every node

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

136 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?based on unapplied earlier transactionssuch conflicts must come for other members/nodes

happens on every member/nodeshould be deterministic on every noderesults are not reported to the group

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

137 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?based on unapplied earlier transactionssuch conflicts must come for other members/nodes

happens on every member/nodeshould be deterministic on every noderesults are not reported to the group

pass: enter in the apply queue

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

138 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?based on unapplied earlier transactionssuch conflicts must come for other members/nodes

happens on every member/nodeshould be deterministic on every noderesults are not reported to the group

pass: enter in the apply queuefail: drop the transaction

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

139 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?based on unapplied earlier transactionssuch conflicts must come for other members/nodes

happens on every member/nodeshould be deterministic on every noderesults are not reported to the group

pass: enter in the apply queuefail: drop the transaction

serialized by the total order in GCS/XCOM + GTID

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

140 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?based on unapplied earlier transactionssuch conflicts must come for other members/nodes

happens on every member/nodeshould be deterministic on every noderesults are not reported to the group

pass: enter in the apply queuefail: drop the transaction

serialized by the total order in GCS/XCOM + GTIDcost is based on trx size (# rows & # keys)

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

141 / 147

CertificationCertification is the process that only needs to answer the following unique question:

can the write (transaction) be applied ?based on unapplied earlier transactionssuch conflicts must come for other members/nodes

happens on every member/nodeshould be deterministic on every noderesults are not reported to the group

pass: enter in the apply queuefail: drop the transaction

serialized by the total order in GCS/XCOM + GTIDcost is based on trx size (# rows & # keys)first committer (and ack from majority) wins rule

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

142 / 147

Drawbacks of optimistic lockinghaving a first-committer-wins system means conflicts will more likely happen whenwriting on multiple members with:

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

143 / 147

Drawbacks of optimistic lockinghaving a first-committer-wins system means conflicts will more likely happen whenwriting on multiple members with:

large transactions

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

144 / 147

Drawbacks of optimistic lockinghaving a first-committer-wins system means conflicts will more likely happen whenwriting on multiple members with:

large transactions

long running transactions

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

145 / 147

Drawbacks of optimistic lockinghaving a first-committer-wins system means conflicts will more likely happen whenwriting on multiple members with:

large transactions

long running transactions

hotspot records

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

146 / 147

Thank you !

Any Questions ?

share your 💕 for MySQL on social media using @MySQL #DataOpsBarcelona

more at http://lefred.be/content/category/mysql/group-replication/http://mysqlhighavailability.com/

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

147 / 147