Replication features of 2011

Similar documents
MySQL Replication Update

Introduction To MySQL Replication. Kenny Gryp Percona Live Washington DC /

MyRocks in MariaDB. Sergei Petrunia MariaDB Tampere Meetup June 2018

Using the MySQL Binary Log as a Change Stream

Improvements in MySQL 5.5 and 5.6. Peter Zaitsev Percona Live NYC May 26,2011

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 8

MySQL Performance Optimization and Troubleshooting with PMM. Peter Zaitsev, CEO, Percona

Riding the Binlog: an in Deep Dissection of the Replication Stream. Jean-François Gagné jeanfrancois DOT gagne AT booking.com

MySQL Point-in-Time Recovery like a Rockstar

New Replication Features MySQL 5.1 and MySQL 6.0/5.4

MyRocks Storage Engine Status Update. Sergei Petrunia MariaDB Meetup New York February, 2018

Performance improvements in MySQL 5.5

MySQL usage of web applications from 1 user to 100 million. Peter Boros RAMP conference 2013

MySQL Database Scalability

Backup & Restore. Maximiliano Bubenick Sr Remote DBA

MySQL Performance Optimization and Troubleshooting with PMM. Peter Zaitsev, CEO, Percona Percona Technical Webinars 9 May 2018

Diagnosing Failures in MySQL Replication

InnoDB: Status, Architecture, and Latest Enhancements

MySQL Multi-Source Replication

Why Choose Percona Server For MySQL? Tyler Duzan

MyRocks deployment at Facebook and Roadmaps. Yoshinori Matsunobu Production Engineer / MySQL Tech Lead, Facebook Feb/2018, #FOSDEM #mysqldevroom

What's new in MySQL 5.5 and 5.6 replication

Load Testing Tools. for Troubleshooting MySQL Concurrency Issues. May, 23, 2018 Sveta Smirnova

How to evaluate which MySQL High Availability solution best suits you

MySQL Replication. Rick Golba and Stephane Combaudon April 15, 2015

Oracle Exam 1z0-883 MySQL 5.6 Database Administrator Version: 8.0 [ Total Questions: 100 ]

MySQL Replication: What's New In MySQL 5.7 and MySQL 8. Luís Soares Software Development Director MySQL Replication

Oracle 1Z MySQL 5.6 Database Administrator. Download Full Version :

InnoDB Scalability Limits. Peter Zaitsev, Vadim Tkachenko Percona Inc MySQL Users Conference 2008 April 14-17, 2008

Switching to Innodb from MyISAM. Matt Yonkovit Percona

How Facebook Got Consistency with MySQL in the Cloud Sam Dunster

Percona XtraDB Cluster

Mix n Match Async and Group Replication for Advanced Replication Setups. Pedro Gomes Software Engineer

Choosing a MySQL High Availability Solution. Marcos Albe, Percona Inc. Live Webinar June 2017

MySQL Replication Advanced Features In 20 minutes

MariaDB 10.3 vs MySQL 8.0. Tyler Duzan, Product Manager Percona

XA Transactions in MySQL

Choosing a MySQL HA Solution Today

Which technology to choose in AWS?

Delegates must have a working knowledge of MariaDB or MySQL Database Administration.

MySQL Replication Tips and Tricks

MySQL Performance Improvements

The Hazards of Multi-writing in a Dual-Master Setup

Binlog Servers at Booking.com. Jean-François Gagné jeanfrancois DOT gagne AT booking.com

Binlog Servers (and MySQL) at Booking.com. Jean-François Gagné jeanfrancois DOT gagne AT booking.com Presented at Percona Live Santa Clara 2015

MySQL Storage Engines Which Do You Use? April, 25, 2017 Sveta Smirnova

How to make MySQL work with Raft. Diancheng Wang & Guangchao Bai Staff Database Alibaba Cloud

Everything You Need to Know About MySQL Group Replication

XtraDB 5.7: Key Performance Algorithms. Laurynas Biveinis Alexey Stroganov Percona

Effective Testing for Live Applications. March, 29, 2018 Sveta Smirnova

MySQL 5.6 New Replication Features

High availability with MariaDB TX: The definitive guide

MySQL 5.6: Advantages in a Nutshell. Peter Zaitsev, CEO, Percona Percona Technical Webinars March 6, 2013

Scale out Read Only Workload by sharing data files of InnoDB. Zhai weixiang Alibaba Cloud

Beyond MySQL 5.1 What is happening in MySQL Space. Feb 16, 2011 Percona Live San Francisco,CA by Peter Zaitsev, Percona Inc

Creating a Best-in-Class Backup and Recovery System for Your MySQL Environment. Akshay Suryawanshi DBA Team Manager,

Optimizing BOINC project databases

Scaling Without Sharding. Baron Schwartz Percona Inc Surge 2010

MySQL Replication : advanced features in all flavours. Giuseppe Maxia Quality Assurance Architect at

MySQL HA Solutions Selecting the best approach to protect access to your data

The Exciting MySQL 5.7 Replication Enhancements

Copyright 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12

TokuDB vs RocksDB. What to choose between two write-optimized DB engines supported by Percona. George O. Lorch III Vlad Lesin

MySQL High Availability. Michael Messina Senior Managing Consultant, Rolta-AdvizeX /

Jailbreaking MySQL Replication Featuring Tungsten Replicator. Robert Hodges, CEO, Continuent

MySQL Group Replication & MySQL InnoDB Cluster

Preventing and Resolving MySQL Downtime. Jervin Real, Michael Coburn Percona

MySQL 101. Designing effective schema for InnoDB. Yves Trudeau April 2015

MySQL Cluster An Introduction

ScaleArc Performance Benchmarking with sysbench

MySQL Security, Privileges & User Management Kenny Gryp Percona Live Washington DC /

Resolving and Preventing MySQL Downtime

ProxySQL - GTID Consistent Reads. Adaptive query routing based on GTID tracking

MySQL Group Replication. Bogdan Kecman MySQL Principal Technical Engineer

MySQL Replication: Latest Developments

MongoDB and Mysql: Which one is a better fit for me? Room 204-2:20PM-3:10PM

Best Practices for Database Administrators

A Brief Introduction of TiDB. Dongxu (Edward) Huang CTO, PingCAP

MySQL High Availability Solutions. Alex Poritskiy Percona

1Z Oracle. MySQL 5 Database Administrator Certified Professional Part I

Lessons from database failures

What s New in MySQL 5.7 Geir Høydalsvik, Sr. Director, MySQL Engineering. Copyright 2015, Oracle and/or its affiliates. All rights reserved.

Percona XtraDB Cluster MySQL Scaling and High Availability with PXC 5.7 Tibor Korocz

Setting up Multi-Source Replication in MariaDB 10.0

<Insert Picture Here> Upcoming Changes in MySQL 5.7 Morgan Tocker, MySQL Community Manager

NoVA MySQL October Meetup. Tim Callaghan VP/Engineering, Tokutek

MariaDB: Community Driven SQL Server. Kristian Nielsen MariaDB developer Monty Program AB

MySQL 8.0: Atomic DDLs Implementation and Impact

MySQL 8.0 Performance: InnoDB Re-Design

Innodb Architecture and Internals. Peter Zaitsev Percona Live, Washington DC 11 January 2012

MySQL HA Solutions. Keeping it simple, kinda! By: Chris Schneider MySQL Architect Ning.com

Choosing a MySQL HA Solution Today. Choosing the best solution among a myriad of options

What's new in MySQL 5.5? Performance/Scale Unleashed

Common MySQL Scalability Mistakes AUTHOR

Meet the Sergei Golubchik MariaDB Corporation

What is MariaDB 5.5? w: e: Daniel Bartholomew Oct 2012

Mysql Cluster Global Schema Lock

How To Rock with MyRocks. Vadim Tkachenko CTO, Percona Webinar, Jan

Introduction to MySQL InnoDB Cluster

CO MySQL for Database Administrators

Transcription:

FOSDEM 2012 Replication features of 2011 What they were How to get them How to use them Sergey Petrunya MariaDB

MySQL Replication in 2011: overview Notable events, chronologically: MySQL 5.5 GA (Dec 2010) MariaDB 5.3 (Beta in June, RC in December) Group commit Replication listener MySQL 5.6 MS releases (April, October, December) 2 14:46:17

MySQL 5.5 MySQL 5.5 merged to Percona Server 5.5 Semi-synchronous replication plugin (delay reporting the commit to client until it is in the relay log of some slave) Slave fsync tuning (sync_relay_log_info, sync_master_info, sync_relay_log) Automatic relay log recovery (--relay-log-recovery=1) Replication Heartbeat (CHANGE MASTER SET master_heartbeat_period=) Per-server filtering (CHANGE MASTER IGNORE_SERVER_IDS=) RBR slave type conversions (--slave-type-conversions=all_{non}_lossy) Individual Log Flushing (FLUSH ERROR RELAY BINARY GENERAL LOGS) SHOW RELAYLOG EVENTS 3 14:46:18

MariaDB 5.3 Releases 5.3.1 Beta- July 2011, 5.3.2 Beta Oct 2011 5.3.3 RC Dec 2011 Replication features Group commit for binary log Annotations for RBR events Checksums for binlog events Percona Server 5.5 MySQL 5.6 Enchancements for START TRANSACTION WITH CONSISTENT SNAPSHOT Optimized RBR for tables without primary key Percona's patch 4 14:46:18

Group commit for binary log To get the D in ACID, one needs InnoDB: innodb_flush_log_at_trx_commit=1 Binlog: sync_binlog=1 When you have both ON, group commit doesn't work ~200 transactions per second max 1600 Another workload 1400 1200 1000 TPS 800 600 trx+binlog No-sync trx 400 200 0 0 20 40 60 80 100 120 140 Threads 5 14:46:18

Group commit for binary log (2) Transactional operation with enabled binlog 1.Write transaction to InnoDB transaction log 2.Write transaction to binlog This is the actual commit 3.Write a commit record to InnoDB. 6 14:46:19

Group commit for binary log (2) Pre-group-commit way to ensure the same ordering: 7 14:46:19

Group commit for binary log (3) Group commit: Multiple implementations: Facebook, MariaDB, proposal by Oracle All different, based on similar ideas: Get tickets when writing to the binlog Fix InnoDB commits in the same order they were done with binlog (Maybe) Split P3 into the fix ordering (fast) and write-out (slow) phases 8 14:46:19

Group commit for binary log So far, MariaDB 5.3 has the best Ported into Percona Server 5.5 Chart from Group commit in MariaDB is fast post by Mark Callaghan 9 14:46:19

MariaDB 5.3: Annotated RBR events Every RBR event is accompanied by its source query Master: --binlog_annotate_row_events Slave: --replicate-annotate-rows-events MariaDB [test]> show binlog events in 'pslp.000299'; +-------------+-----+---------------+-----------+-------------+-------------------------------------------------+ Log_name Pos Event_type Server_id End_log_pos Info +-------------+-----+---------------+-----------+-------------+-------------------------------------------------+ pslp.000299 4 Format_desc 1 245 Server ver: 5.3.4-MariaDB-rc-log, Binlog ver: 4 pslp.000299 245 Query 1 313 BEGIN pslp.000299 313 Annotate_rows 1 379 /* app1 */ insert into t1 values('foo'),('bar') pslp.000299 379 Table_map 1 422 table_id: 15 (test.t1) pslp.000299 422 Write_rows 1 461 table_id: 15 flags: STMT_END_F pslp.000299 461 Query 1 530 COMMIT pslp.000299 530 Query 1 598 BEGIN pslp.000299 598 Annotate_rows 1 664 /* app2 */ update t1 set a='test' where a='foo' pslp.000299 664 Table_map 1 707 table_id: 15 (test.t1) pslp.000299 707 Update_rows 1 759 table_id: 15 flags: STMT_END_F +-------------+-----+---------------+-----------+-------------+-------------------------------------------------+ # at 379 # at 422 #120203 16:25:11 server id 1 end_log_pos 379 Annotate_rows: #Q> /* app1 */ insert into t1 values('foo'),('bar') #120203 16:25:11 server id 1 end_log_pos 422 Table_map: `test`.`t1` mapped to number 15 #120203 16:25:11 server id 1 end_log_pos 461 Write_rows: table id 15 flags: STMT_END_F BINLOG ' J9IrTxMBAAAAKwAAAKYBAAAAAA8AAAAAAAEABHRlc3QAAnQxAAEPAgwAAQ== 10 14:46:19

MySQL 5.6: annotated events, too Implementation is [naturally] very similar to MariaDB's. The user interface is different: Master: --binlog-rows-query-log-events MySQL [test]> show binlog events; +-------------+-----+-------------+-----------+-------------+---------------------------------------------------+ Log_name Pos Event_type Server_id End_log_pos Info +-------------+-----+-------------+-----------+-------------+---------------------------------------------------+ pslp.000001 4 Format_desc 1 114 Server ver: 5.6.5-m8-debug-log, Binlog ver: 4 pslp.000001 114 Query 1 215 use `test`; create table t1 (a varchar(12)) pslp.000001 215 Query 1 283 BEGIN pslp.000001 283 Rows_query 1 350 # /* app1 */ insert into t1 values('foo'),('bar') pslp.000001 350 Table_map 1 393 table_id: 66 (test.t1) pslp.000001 393 Write_rows 1 432 table_id: 66 flags: STMT_END_F pslp.000001 432 Xid 1 459 COMMIT /* xid=5 */ pslp.000001 459 Query 1 527 BEGIN pslp.000001 527 Rows_query 1 594 # /* app2 */ update t1 set a='test' where a='foo' pslp.000001 594 Table_map 1 637 table_id: 66 (test.t1) pslp.000001 637 Update_rows 1 678 table_id: 66 flags: STMT_END_F pslp.000001 678 Xid 1 705 COMMIT /* xid=6 */ +-------------+-----+-------------+-----------+-------------+---------------------------------------------------+ 11

A compatibility problem MariaDB 5.3 added Annotate_rows event MySQL 5.6 added Rows_query event They are different events MariaDB 5.3 can't understand Rows_query MySQL 5.6 can't understand Annotate_rows Seeing unknown event in binlog error (It is not safe to continue after you've skipped an unknown operation) MySQL 5.6 will have a flag to mark ignorable binlog events We'll merge this to MariaDB This will make binary logs compatible again 12

Optimized RBR for tables with no PK An RBR event is essentially something like this: with table $tbl=`dbname.tablename` (col1 INT, col2 CHAR(N),...) do delete in $tbl row with (col1,col2) = (10, 'foo') Execution before MariaDB 5.3 Use the *first* index to find records If the table has PRIMARY KEY is present, it will be the first (OK) If there is no PK, may end up using poor index If it is an FT index, replication stops with error In MariaDB 5.3 1. If there is a PRIMARY KEY, use it 2. Otherwise, use first UNIQUE index w/o NULLs 3. Otherwise, use the most-selective non-fulltext index 13

MySQL 5.6 Crash-safe slave replication info tables Crash-safe master binary log recovery Replication event checksums Time delayed replication Optimized row-based logging --binlog_row_image={full,minimal,noblob} Informational log events Remote backup of binary logs Server UUIDs Replication topology detection Parallel event execution on slave MariaDB 5.3 14

Parallel event execution: background Slave SQL thread algorithm: while (get next next event from relay log) { execute event; } Problems Cannot use multiple CPUs Cannot enqueue multiple disk requests => slave may be unable to keep up with the master 15

Solution#1: Parallel slave The idea: execute binlog events in parallel Problems to address: Out-of-order event execution must produce the same result Slave may be in a state that never existed on the master Including being in this state after the crash 16

MySQL 5.6's parallel slave Basic idea: partition events by hash (db_name) Changes to different db's can be ran out-of-order This should be ok for your application, too Exec_Master_Log_Pos is a lowwatermark now Slave keeps track of what was commited above the watermark and will use it for recovery The main problem Un-even distribution of load between workers (picture from Lars Thallman's OSCON 2011 talk) A frequent case: most of updates are in one huge table 17

Alternate approach #1: pre-heating IO-bound SQL thread can be made faster by Pre-read relay log Convert UPDATEs/DELETEs to SELECTs Execute the SELECTs Will cause relevant pages be pre-loaded into buffer pool Can be done in parallel First implementation: mk-slave-prefetch Written in Perl Baron Schwartz (author): Don't use it unless you're Facebook Second implementation Replication Booster by Yoshinori Matsunobu 18

Replication booster http://yoshinorimatsunobu.blogspot.com/2011/10/making slave pre fetching work better.html Replication booster Written in C++ using mysql-replication-listener API Uses regexps to convert UPDATEs/DELETEs to SELECTs Doesn't support RBR events Uses multiple threads to parse/re-write binlog events Keeps itself 0..3 sec ahead of the SQL thread Performance improvements Benchmark: from 1779 updates/sec to 5,418 updates/sec 30..300% improvement on various slaves No negative impact when all data is already in cache 19

Alternative approach #2: group commit A possible future development in MariaDB. Basic idea: commits in a group do not conflict They were in Prepare stage together Hence, commits from the same group can be done out-oforder, in parallel 20

Alternative approach #2: group commit (2) How does the slave know which commits were in a group? Master should write markers into the binlog Pro Can be better than hash(db_name) approach of MySQL 5.6 Especially for the all updates hit one-big-table case Contra Grouping in binlog depends on how much the master was loaded 21

2011 in replication Performance improvements Group commit for the binary log (MariaDB 5.3, Percona 5.5) Multi-Threaded Slave (MySQL 5.6) Row-Based Replication RBR event annotation (MariaDB 5.3, MySQL 5.6) binlog_row_image={full,minimal,noblob} (MySQL 5.6) Speedup for RBR of tables without PK (Percona~>MariaDB 5.3) Safety Binlog checksums (MySQL 5.6 -> MariaDB 5.3) Crash-safe master, Crash-save slave (MySQL 5.6) Pseudo-slaves Misc launchpad.net/mysql-replication-listener mysqlbinlog --read-from-remote-server raw (MySQL 5.6) Delayed replication (MySQL 5.6) START TRX WITH CONSISTENT SNAPSHOT (MariaDB 5.3) 22

Links Most of replication developers blog! http://www.mysqlperformanceblog.com http://www.facebook.com/mysqlatfacebook http://kristiannielsen.livejournal.com/ http://mysqlmusings.blogspot.com/ http://yoshinorimatsunobu.blogspot.com http://datacharmer.blogspot.com/ http://d2-systems.blogspot.com/ (hopefully didn't forget anyone) 23

Thanks! Q & A 24 14:46:21