MySQL Manchester TT - Replication Features

63
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | Wednesday, September 23, 2015 Percona Live Amsterdam The Latest and Greatest MySQL 5.7 ReplicaGon Features and More! Mark Swarbrick Principal Presales Consultant UK&I 1

Transcript of MySQL Manchester TT - Replication Features

Page 1: MySQL Manchester TT  - Replication Features

Copyright  ©  2015,  Oracle  and/or  its  affiliates.  All  rights  reserved.    |  Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam    

The  Latest  and  Greatest  MySQL  5.7  ReplicaGon  Features  and  More!  

Mark  Swarbrick  Principal  Presales  Consultant  UK&I  

 

1  

Page 2: MySQL Manchester TT  - Replication Features

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

Safe  Harbor  Statement  The  following  is  intended  to  outline  our  general  product  direcGon.  It  is  intended  for  informaGon  purposes  only,  and  may  not  be  incorporated  into  any  contract.  It  is  not  a  commitment  to  deliver  any  material,  code,  or  funcGonality,  and  should  not  be  relied  upon  in  making  purchasing  decisions.  The  development,  release,  and  Gming  of  any  features  or  funcGonality  described  for  Oracle’s  products  remains  at  the  sole  discreGon  of  Oracle.  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     2  

Page 3: MySQL Manchester TT  - Replication Features

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

Program  Agenda  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam    

Page 4: MySQL Manchester TT  - Replication Features

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

Program  Agenda  Background  

ReplicaGon  Features  in  MySQL  5.7  

News  From  The  Lab!  

The  Road  Ahead!  

Conclusion  

1  

2  

3  

4  

5  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     4  

Page 5: MySQL Manchester TT  - Replication Features

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

Background  1  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam    

Page 6: MySQL Manchester TT  - Replication Features

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

Background:  ReplicaGon  Components  

Wednesday,  September  23,  2015  

Insert...  

         

Insert...      

B  

binary  log  

Insert...      

relay  log            

Insert...      

A  

binary  log  

Client  Sender  thread  

Receiver  thread  

Applier  Threads  

 Receiver  Meta-­‐data  Update  

 

Applier  Meta-­‐data  Update  

Network  

Percona  Live  -­‐  Amsterdam     6  

Page 7: MySQL Manchester TT  - Replication Features

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

Background:  ReplicaGon  Components  • Binary  Log  

– File  based  logical  log  that  records  the  changes  on  the  master.  – Statement  or  Row  based  format  (may  be  intermixed).  – Each  transacGons  is  split  into  groups  of  events.  – Control  events:  Rotate,  Format  DescripGon,  GGd,  ...  

 

Wednesday,  September  23,  2015  

Layout  of  a    Binary  Log  File  

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

Percona  Live  -­‐  Amsterdam     7  

Page 8: MySQL Manchester TT  - Replication Features

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

M   S  

S  

S  

S  

M  

write  clients   read  clients  read  clients  

write  clients  

More  reads?  More  slaves!  

Read  scale-­‐out    

Background:  What  is  ReplicaGon  Used  For?  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     8  

Page 9: MySQL Manchester TT  - Replication Features

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

M   M?  

write  clients   write  clients  

More  writes?  More  

Masters?  

M?  

M?  

What  about  write  scale-­‐out?  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     9  

Page 10: MySQL Manchester TT  - Replication Features

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

C  

B  

A  

C  

B  

A  Crash  

C  

B  

A  

B  is  the  new  master  

Uh  Oh!   Whew!  

Redundancy:  If  master  crashes,  promote  slave  to  master    

Background:  What  is  ReplicaGon  Used  For?  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     10  

Page 11: MySQL Manchester TT  - Replication Features

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

M  

S  

write  clients  

business  intelligent  client  applicaGons  reporGng  client  applicaGons  big  queries  client  applicaGons  

On-­‐line  Backup  and  ReporPng  Background:  What  is  ReplicaGon  Used  For?  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     11  

Page 12: MySQL Manchester TT  - Replication Features

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

C  B  

B  A  A  C  

Image  from  www.ginkgomaps.com  

Background:  What  is  ReplicaPon  Used  For?  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     12  

Page 13: MySQL Manchester TT  - Replication Features

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

ReplicaGon  Features  in  MySQL  5.7  2  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam    

Page 14: MySQL Manchester TT  - Replication Features

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

ReplicaGon  Features  in  MySQL  5.7                          Usability  /  Online    

2  

Wednesday,  September  23,  2015  

2.1  

Percona  Live  -­‐  Amsterdam    

Page 15: MySQL Manchester TT  - Replication Features

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

Online  ReconfiguraGon  of  Global  TransacGon  IdenGfiers  

Wednesday,  September  23,  2015  

Insert...  

         

Insert...      

B  

binary  log  

Insert...      

relay  log            

Insert...      

A  

binary  log  

Client  Sender  thread  

Receiver  thread  

Applier  Threads  

 Receiver  Meta-­‐data  Update  

 

Applier  Meta-­‐data  Update  

Network  

Percona  Live  -­‐  Amsterdam     15  

Page 16: MySQL Manchester TT  - Replication Features

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

Online  ReconfiguraGon  of  Global  TransacGon  IdenGfiers  •  The  procedure  is  online.  

– Both  reads  and  writes  are  allowed  while  global  transacGon  idenGfiers  are  being  turned  on  or  off  in  the  enGre  replicaGon  cluster.  

• No  need  to  synchronize  servers,  ever.  • No  need  to  restart  servers.  • No  need  to  change  replicaGon  topology.  

– Works  in  arbitrary  topologies.  

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

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     16  

Page 17: MySQL Manchester TT  - Replication Features

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

Online  ReconfiguraGon  of  ReplicaGon  Filters  

Wednesday,  September  23,  2015  

Insert...  

         

Insert...      

B  

binary  log  

Insert...      

relay  log            

Insert...      

A  

binary  log  

Client  Sender  thread  

Receiver  thread  

Applier  Threads  

 Receiver  Meta-­‐data  Update  

 

Applier  Meta-­‐data  Update  

Network  

Percona  Live  -­‐  Amsterdam     17  

Page 18: MySQL Manchester TT  - Replication Features

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

Online  ReconfiguraGon  of  ReplicaGon  Filters  • Change  Slave's  ReplicaGon  Filters  dynamically.  

– No  need  to  stop  and  restart  the  slave  server  for  sejng  new  replicaGon  filtering  rules.  – All  slave  filters  are  supported.  – Values  can  be  input  in  various  character  sets.  

Wednesday,  September  23,  2015  

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

Percona  Live  -­‐  Amsterdam     18  

Page 19: MySQL Manchester TT  - Replication Features

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

Online  Switch/Fail-­‐over  to  a  new  Master  

Wednesday,  September  23,  2015  

Insert...  

         

Insert...      

B  

binary  log  

Insert...      

relay  log            

Insert...      

A  

binary  log  

Client  Sender  thread  

Receiver  thread  

Applier  Threads  

 Receiver  Meta-­‐data  Update  

 

Applier  Meta-­‐data  Update  

Network  

Percona  Live  -­‐  Amsterdam     19  

Page 20: MySQL Manchester TT  - Replication Features

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

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

Online  Switch/Fail-­‐over  to  a  new  Master  

Wednesday,  September  23,  2015  

C  

B  

A  

C  

B  

A  Crash  

C  

B  

A  

B  is  the  new  master  

Uh  Oh!   Whew!  

Percona  Live  -­‐  Amsterdam     20  

Page 21: MySQL Manchester TT  - Replication Features

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

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

Online  Switch/Fail-­‐over  to  a  new  Master  

Wednesday,  September  23,  2015  

C  

B  

A  

C  

B  

A  Crash  

C  

B  

A  Uh  Oh!   Whew!  

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

Percona  Live  -­‐  Amsterdam     21  

Page 22: MySQL Manchester TT  - Replication Features

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

Online  Switch/Fail-­‐over  to  a  new  Master  •  Enables  more  online  operaGons  during  fail-­‐over:  

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

• Change  applier  properGes  while  the  receiver  thread  is  working:  

Wednesday,  September  23,  2015  

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;

Percona  Live  -­‐  Amsterdam     22  

Page 23: MySQL Manchester TT  - Replication Features

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

Improved  ReplicaGon  Monitoring  

Wednesday,  September  23,  2015  

Insert...  

         

Insert...      

B  

binary  log  

Insert...      

relay  log            

Insert...      

A  

binary  log  

Client  Sender  thread  

Receiver  thread  

Applier  Threads  

 Receiver  Meta-­‐data  Update  

 

Applier  Meta-­‐data  Update  

Network  

Percona  Live  -­‐  Amsterdam     23  

DBA  

Page 24: MySQL Manchester TT  - Replication Features

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

Improved  ReplicaGon  Monitoring  

• Monitoring  through  SQL.  •  Logically  unrelated  informaGon  into  different  places.  •  Extensible,  can  be  adapted  to  new  features.    • More  accurate  and  consistent  idenGfier  names.  • Master-­‐slave,  MulG-­‐source,  Group  ReplicaGon  support.    

Performance  Schema  ReplicaPon  Tables    

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     24  

Page 25: MySQL Manchester TT  - Replication Features

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

Improved  ReplicaGon  Monitoring  

Wednesday,  September  23,  2015  

ConnecPon    ConfiguraPon  

ConnecPon    Status  

   Applier    ConfiguraPon  

       Applier          Status  

(Slave)  Receiver  and  Applier  Status  

Applier  /  Coordinator  Status  

Workers  Status  

Percona  Live  -­‐  Amsterdam     25  

Page 26: MySQL Manchester TT  - Replication Features

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

ReplicaGon  Features  in  MySQL  5.7                          Usability  /  Online                                      Performance    

2  

Wednesday,  September  23,  2015  

2.1  

2.2  

Percona  Live  -­‐  Amsterdam    

Page 27: MySQL Manchester TT  - Replication Features

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

Improved  Applier  Throughput  –  Locking-­‐based  Parallelism  

Wednesday,  September  23,  2015  

S ingle  Threaded  Apply 8  Threads  Applier 24  Threads  Applier 48  Threads  Applier 96  Threads  Applier0%

50%

100%

150%

200%

250%

F as t  and  S c alable  Multi-­‐threaded  Replic ation  Applier

(s tatement-­‐bas ed  replication,  durable  s ettings ,  S S D  s torage)

Slav

e  ap

ply  tim

e  (S

ysbe

nch  RW

 on  the  mas

ter  w

ith  96  thread

s  =  10

0%)

10X  

Percona  Live  -­‐  Amsterdam     27  

Page 28: MySQL Manchester TT  - Replication Features

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

Improved  Applier  Throughput  –  Locking-­‐based  Parallelism  •  Leverage  parallelizaGon  informaGon  from  master  execuGon:  

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

• Meanwhile,  at  the  slave:  – Non-­‐contending  transacGons  are  scheduled  in  parallel;  – Concurrent  transacGons  commit  independently,  thus  no  waiPng  involved.  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     28  

Page 29: MySQL Manchester TT  - Replication Features

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

 Wednesday,  September  23,  2015  

T1  

T2  

T3  

Time  

Commit  Finishes  

Last  Lock  Acquired  

Concurrent  ExecuGon  History    on  the  Master  

ExecuPon  

Commit  

T1  and  T2  execute  in  parallel  on  the  slave.  

T2  and  T3  execute  in    parallel  on  the  slave.  

Percona  Live  -­‐  Amsterdam     29  

Page 30: MySQL Manchester TT  - Replication Features

Copyright  ©  2015,  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  Gmestamps.  – database  -­‐  the  scheduling  policy  from  5.6  (concurrency  control  done  per  database).  

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

Wednesday,  September  23,  2015  

mysql>  SET  slave_parallel_type=  [logical_clock|database]    

Percona  Live  -­‐  Amsterdam     30  

Page 31: MySQL Manchester TT  - Replication Features

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

Improved  User  Threads-­‐Sender  Threads  SynchronizaGon  

Wednesday,  September  23,  2015  

Insert...  

         

Insert...      

B  

binary  log  

Insert...      

relay  log            

Insert...      

A  

binary  log  

Client  Sender  thread  

Receiver  thread  

Applier  Threads  

 Receiver  Meta-­‐data  Update  

 

Applier  Meta-­‐data  Update  

Network  

Percona  Live  -­‐  Amsterdam     31  

Page 32: MySQL Manchester TT  - Replication Features

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

Improved  User  Threads-­‐Sender  Threads  SynchronizaGon  • 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.  

Wednesday,  September  23,  2015  

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+  

Percona  Live  -­‐  Amsterdam     32  

Page 33: MySQL Manchester TT  - Replication Features

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

Faster  Sender  Thread  •  Ad  hoc  microbenchmark  using  mysqlslap  

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

•  N  slaves  aoached  (fake  slaves  using  remote  mysqlbinlogs)  

•  48  cores  HT  /  512  GB  RAM  /  HDD  

Wednesday,  September  23,  2015  

   

0  2000  4000  6000  8000  

10000  12000  14000  16000  

1   2   3   4   5   6   7   8   9  

QpS  

Number  of  Connected    Sender  Threads  

Master’s  Throughput  

MySQL  5.6.16   MySQL  5.7.4  

Percona  Live  -­‐  Amsterdam     33  

Page 34: MySQL Manchester TT  - Replication Features

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

Faster  Semi-­‐sync  ReplicaGon  –  ACK  Receiver  Thread  

Wednesday,  September  23,  2015  

Insert...  

         

Insert...      

B  

binary  log  

Insert...      

relay  log            

Insert...      

A  

binary  log  

Client  

ACK  Receiver  thread  

Receiver  thread  

Applier  Threads  

 Receiver  Meta-­‐data  Update  

 

Applier  Meta-­‐data  Update  

Network  

Sender  thread  

Percona  Live  -­‐  Amsterdam     34  

Page 35: MySQL Manchester TT  - Replication Features

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

Faster  Semi-­‐sync  ReplicaGon  –  ACK  Receiver  Thread  • ConsecuGve  transacGons  do  not  block  each  other  while  waiGng  for  ACKs  

– TransacGon  t1  and  t2  are  sent  immediately  to  the  slave  by  the  sender  thread  – ACKs  are  received  only  by  a  special  thread  – TransacGon  t2  does  not  include  t1  round  trip  in  its  semi-­‐sync  overall  latency  

•  Thread  starts  when  semi-­‐sync  is  acGvated  

•  Thread  stops  when  semi-­‐sync  is  deacGvated  

Wednesday,  September  23,  2015  

mysql>  SET  GLOBAL  rpl_semi_master_enabled=  ON  

mysql>  SET  GLOBAL  rpl_semi_master_enabled=  OFF  

Percona  Live  -­‐  Amsterdam     35  

Page 36: MySQL Manchester TT  - Replication Features

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

Faster  Semi-­‐sync:  Durability  over  the  Network  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     36  

Page 37: MySQL Manchester TT  - Replication Features

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

ReplicaGon  Features  in  MySQL  5.7                          Usability  /  Online                                      Performance                            Dependability    

2  

Wednesday,  September  23,  2015  

2.1  

2.2  

2.3  

Percona  Live  -­‐  Amsterdam    

Page 38: MySQL Manchester TT  - Replication Features

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

Loss-­‐less  Semi-­‐sync  ReplicaGon  

Wednesday,  September  23,  2015  

Insert...  

         

Insert...      

B  

binary  log  

Insert...      

relay  log            

Insert...      

A  

binary  log  

Client  Sender  thread  

Receiver  thread  

Applier  Threads  

 Receiver  Meta-­‐data  Update  

 

Applier  Meta-­‐data  Update  

Network  

Percona  Live  -­‐  Amsterdam     38  

Page 39: MySQL Manchester TT  - Replication Features

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

Loss-­‐less  Semi-­‐sync  ReplicaGon  

Wednesday,  September  23,  2015  

Master  

Slave  

T1:  INSERT  INTO  t1  VALUES  (1000)  

ACK  

Time  

T2:  SELECT  *  FROM  t1;   empty  set  

execute   prepare   binlog  

relay  log  

commit  execute  

Percona  Live  -­‐  Amsterdam     39  

Page 40: MySQL Manchester TT  - Replication Features

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

Loss-­‐less  Semi-­‐sync  ReplicaGon  • Master  waits  for  slave's  ACK  before  commijng  (as  opposed  to:  master  waits  for  slave's  ACK  aier  commijng).  – Therefore,  concurrent  transacGons  do  not  see  changes  while  this  transacGon  waits  for  ack.  

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

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

Wednesday,  September  23,  2015  

mysql>  SET  rpl_semi_sync_master_wait_point=  [AFTER_SYNC|AFTER_COMMIT]  

Percona  Live  -­‐  Amsterdam     40  

Page 41: MySQL Manchester TT  - Replication Features

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

Semi-­‐sync  ReplicaGon  –  Wait  for  MulGple  ACKs  

Wednesday,  September  23,  2015  

Insert...  

         

Insert...      

B  

binary  log  

Insert...      

relay  log            

Insert...      

A  

binary  log  

Client  Sender  thread  

Receiver  thread  

Applier  Threads  

 Receiver  Meta-­‐data  Update  

 

Applier  Meta-­‐data  Update  

Network  

Percona  Live  -­‐  Amsterdam     41  

Page 42: MySQL Manchester TT  - Replication Features

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

Semi-­‐sync  ReplicaGon  –  Wait  for  MulGple  ACKs  • Master  does  not  commit  transacGon  unGl  it  receives  N  ACKs  from  N  slaves.  • Dynamically  seoable:  

Wednesday,  September  23,  2015  

mysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= N

Percona  Live  -­‐  Amsterdam     42  

Page 43: MySQL Manchester TT  - Replication Features

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

Semi-­‐sync  ReplicaGon  –  Wait  for  MulGple  ACKs  • Master  does  not  commit  transacGon  unGl  it  receives  N  ACKs  from  N  slaves.  • Dynamically  seoable:  

Wednesday,  September  23,  2015  

mysql> SET GLOBAL rpl_semi_sync_master_wait_for_slave_count= N

Master  

Slave  2  

T1:  COMMIT  

ACK  Slave  1  

ACK  

T1:  COMMIT  succeeds  

mysql>  SET  GLOBAL  rpl_semi_sync_master_wait_for_slave_count=  2  

Slave  3  Time

relay  log  

relay  log  

relay  log  

Percona  Live  -­‐  Amsterdam     43  

ACK  

Page 44: MySQL Manchester TT  - Replication Features

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

ReplicaGon  Features  in  MySQL  5.7                          Usability  /  Online                                      Performance                            Dependability                            Flexibility    

2  

Wednesday,  September  23,  2015  

2.1  

2.2  

2.3  

2.4  

Percona  Live  -­‐  Amsterdam    

Page 45: MySQL Manchester TT  - Replication Features

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

Storing  Global  TransacGon  IdenGfiers  in  a  Table  

Wednesday,  September  23,  2015  

Insert...  

         

B  Insert...  

   

relay  log            

Insert...      

A  

binary  log  

Client  Sender  thread  

Receiver  thread  

Applier  Threads  

 Receiver  Meta-­‐data  Update  

 

Applier  Meta-­‐data  Update  

Network  

Percona  Live  -­‐  Amsterdam     45  

Page 46: MySQL Manchester TT  - Replication Features

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

Storing  Global  TransacGon  IdenGfiers  in  a  Table  

•  Slaves  can  use  GTIDs  with  binary  logs  disabled.  – Slaves  that  are  never  candidates  to  become  a  master  can  sGll  use  GTIDs  for  auto  posiGoning.  

Use  Cases    

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     46  

Page 47: MySQL Manchester TT  - Replication Features

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

Storing  Global  TransacGon  IdenGfiers  in  a  Table  

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

• GTIDs  are  inserted  into  the  table  as  transacGons  commit.  • A  compression  thread  runs  periodically  and  compresses  the  table  into  ranges.  – New  global  variable  controls  the  period:  gGd_executed_compression_period.  

Mechanics    

Wednesday,  September  23,  2015  

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)

Percona  Live  -­‐  Amsterdam     47  

Page 48: MySQL Manchester TT  - Replication Features

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

Storing  Global  TransacGon  IdenGfiers  in  a  Table  

• Binary  Log  Enabled  – Store  GTID  in  binary  log  (transacGonally).  – Copy  GTID  set  to  table  on  binary  log  rotaGon.  

• Binary  Log  Disabled  – Store  GTID  in  table  (transacGonally).  – New  transacGons  are  not  assigned  a  GTID.  

• Always  store  GTIDs  transacGonally.  

Mechanics    

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     48  

Page 49: MySQL Manchester TT  - Replication Features

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

MulG-­‐Source  ReplicaGon  

Wednesday,  September  23,  2015  

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  analyGcs  purposes;  •  Data  HUB  for  inter-­‐cluster  replicaGon.  

Percona  Live  -­‐  Amsterdam     49  

Page 50: MySQL Manchester TT  - Replication Features

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

MulG-­‐Source  ReplicaGon  •  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.  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     50  

Page 51: MySQL Manchester TT  - Replication Features

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

ReplicaGon  Features  in  MySQL  5.7                          Usability  /  Online                                      Performance                            Dependability                            Flexibility                            Misc    

2  

Wednesday,  September  23,  2015  

2.1  

2.2  

2.3  

2.4  

2.4  

Percona  Live  -­‐  Amsterdam    

Page 52: MySQL Manchester TT  - Replication Features

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

“Smaller”,  yet  interesPng,  enhancements!  • MulP-­‐threaded  applier  is  able  to  retry  failed  transacPons.  •  OpGon  to  make  the  MulP-­‐threaded  applier  preserve  commit  order.  

•  SSL  opGons  for  mysqlbinlog  tool.  

•  Rewrite  DB  rules  for  the  mysqlbinlog  tool.  

•  FuncPon  to  wait  for  transacPons  to  be  applied,  regardless  of  the  replicaGon  stream  they  come  from.  

•  OpGons  to  track  global  transacPon  idenPfiers  in  the  return  packet  of  the  mysql  protocol.  

•  Support  for  XA  transacPons  when  the  binary  log  is  enabled.  •  Change  in  the  defaults.  E.g.,  binlog_format=ROW  and  sync_binlog=1.  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     52  

Page 53: MySQL Manchester TT  - Replication Features

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

News  From  The  Lab!  3  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam    

Page 54: MySQL Manchester TT  - Replication Features

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

MySQL  Group  ReplicaGon  Plugin  

Wednesday,  September  23,  2015  

M   M   M   M   M  

ReplicaPon  Group  

•  MulG-­‐master  update  everywhere  •  AutomaPc  group  membership  

management  and  failure  detecPon.  

•  No  need  for  server  fail-­‐over.  •  AutomaPc  reconfiguraPon.  

•  No  single  point  of  failure.  •  Shared-­‐nothing  state  machine  

replicaGon.  

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

Percona  Live  -­‐  Amsterdam     54  

Page 55: MySQL Manchester TT  - Replication Features

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

MySQL  Group  ReplicaGon  Plugin  • Great  technology  for  deployments  where  elasGcity  is  a  requirement,  such  as  cloud  based  infrastructures.  – Integrated  with  the  server  core  through  a  well  defined  API.  – It  is  integrated  with  GTIDs,  row  based  replicaGon.  – It  is  integrated  with  performance  schema  tables.  – It  is  elasGc  and  self-­‐healing:  adding  or  removing  servers  does  not  need  human  intervenGon.  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     55  

Page 56: MySQL Manchester TT  - Replication Features

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

MySQL  Router  • MoGvaGon  

– The  need  for  transparent  integraGon  with  Fabric.  •  No  need  to  upgrade  exisGng  connectors.  •  Use  Fabric  with  connectors  that  do  not  support  it  (e.g.,  PHP,  Ruby,  Perl,  C).  

– The  need  for  read-­‐write  and  read-­‐only  automaGc  rouGng.  •  Do  not  need  to  know  which  server  is  the  master.  •  Transparent  fail-­‐over  support  for  a  new  master.  

•  End  Result  – Generic  and  versaGle  framework:  MySQL  Router.    

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam    

NEW  

M  

Router  

App  

M   M  

Fabric  

56  

Page 57: MySQL Manchester TT  - Replication Features

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

MySQL  Router  • Highlights  

– High  Performance  – Plugin  Driven  Architecture  – Simple  to  setup,  configure  and  deploy.  

•  Features  – ConnecGon  rouGng  and  simple  load  balancing.  – Seamless  fail-­‐over  based  on  Fabric  HA  Groups.  – Fail-­‐over  without  Fabric  (needs  3rd  party  tool  to  handle  fail-­‐over  itself).  

– reducing  conflicts  when  deployed  together  with  Group  ReplicaGon.  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam    

M  

Router  

App  

M   M  

Fabric  

NEW  

57  

Page 58: MySQL Manchester TT  - Replication Features

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

The  Road  Ahead!  4  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam    

Page 59: MySQL Manchester TT  - Replication Features

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

What  is  Next?  • MySQL  Group  ReplicaPon  

– Rapid  releases.  – Improve  performance,  stability  and  usability.  

• MySQL  ReplicaGon  Usability  – Instrument  even  more  replicaGon  and  extend  replicaGon  P_S  tables  – Simpler  administraGve  commands  

• MySQL  ReplicaGon  Performance  – ConGnue  to  improve  mulG-­‐threaded  (slave)  applier  – ConGnue  to  improve  semi-­‐sync  

• MySQL  Fabric  and  MySQL  Router  inter-­‐operability  Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     59  

Page 60: MySQL Manchester TT  - Replication Features

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

Summary  7  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam    

Page 61: MySQL Manchester TT  - Replication Features

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

Summary  •  ReplicaGon  feature  set  in  MySQL  5.7  shows  many  improvements:  

– Semi-­‐sync  is  more  flexible  and  faster.  – Less  contenGon  on  the  binary  log.  – Slave  is  faster  and  provides  an  inter-­‐transacGon  parallelizaGon  scheme.  – More  online  reconfiguraGon:  Global  TransacGon  IdenGfiers,  filters,  configuraGon.  – Improved  monitoring.  – Even  more  flexible  replicaGon  with  mulG-­‐source  enabling  new  deployment  scenarios.  – Enhancements  all  over:  transacGon  retries,  sequenGal  commits,  XA  support,  new  replicaGon  funcGons,  security.  

•  Lab  releases  provide  a  sneak  peek  at  what  is  coming  -­‐  a  new  replicaGon  plugin  and  exciGng  new  infrastructure:  MySQL  Group  ReplicaPon  and  MySQL  Router.  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     61  

Page 62: MySQL Manchester TT  - Replication Features

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

Where  to  go  from  here?  • Packages  

– hop://dev.mysql.com  – hop://labs.mysql.com  

• Reference  DocumentaGon  – hop://dev.mysql.com/doc/#manual  

• Blogs  from  the  Engineers  (news,  quirks,  technical  informaGon  and  much  more)  – hop://mysqlhighavailability.com  

Wednesday,  September  23,  2015   Percona  Live  -­‐  Amsterdam     62  

Page 63: MySQL Manchester TT  - Replication Features