SlideShare a Scribd company logo
1 of 78
Download to read offline
How to Avoid Pitfalls in Schema Upgrade
with Percona XtraDB Cluster
Sveta Smirnova
Percona
Sveta Smirnova
• MySQL Support engineer
• Author of
• MySQL Troubleshooting
• JSON UDF functions
• FILTER clause for MySQL
• Speaker
• Percona Live, OOW, Fosdem,
DevConf, HighLoad... 2
Table of Contents
•TOI
•RSU
•pt-online-schema-change (pt-osc)
3
Introduction
• Galera Replication Library
• Provides synchronous replication for MySQL
4
Introduction
• Galera Replication Library
• Provides synchronous replication for MySQL
• Galera Clusters
Percona XtraDB Cluster
MariaDB Galera Cluster
Galera Cluster for MySQL
4
How Galera works
• Data modification happens on a node
• Optimistic locking control
5
How Galera works
• Data modification happens on a node
• Optimistic locking control
• While a transaction is in progress
• Writes are applied locally
• Same as for standalone server
5
How Galera works
• Data modification happens on a node
• Optimistic locking control
• While a transaction is in progress
• At the COMMIT time
• Broadcasts write set for the cluster
• Waits confirmation of the successful update
From all other nodes
Yes Commits transaction locally
No Rollbacks transaction
5
Data Updates
• Committed on all nodes or nowhere
• Safe
6
Challenges of DDL
• Replicated independently from storage engine
7
Challenges of DDL
• Replicated independently from storage engine
• Changes may affect query results
• Adding/removal of UNIQUE keys
• Adding/removal columns
• Changing column definition
7
Challenges of DDL
• Replicated independently from storage engine
• Changes may affect query results
• Modification can happen on any node
• The schema must be upgraded before DML
• There is no way to rollback schema upgrade
• MDLs are set only on one node
Not across the cluster
Not possible to rely on them for all nodes
Additional control required
7
TOI
Total Order Isolation (TOI)
• DDL changes are replicated in the same order
• Regarding other transactions
• All nodes are in the absolutely same state
• At any point of time
9
TOI: Illustration
• 3-nodes cluster
• Node A
• Node B
• Node C
10
TOI: Illustration
• Initial state
Node A
INSERT(103)
UPDATE(104)
ALTER(105)
Node B
UPDATE(101)
INSERT(102)
DELETE(108)
UPDATE(109)
Node C
SELECT(100)
INSERT(112)
SELECT(113)
UPDATE(114)
10
TOI: Illustration
• Queries status
Node A
INSERT(103)
UPDATE(104)
ALTER(105)
Node B
UPDATE(101)
INSERT(102)
DELETE(108)
UPDATE(109)
Node C
SELECT(100)
INSERT(112)
SELECT(113)
UPDATE(114)
10
TOI: Illustration
• ALTER in progress
Node A
ALTER(105)
Node B
DELETE(108)
UPDATE(109)
Node C
INSERT(112)
SELECT(113)
UPDATE(114)
10
TOI: Illustration
• ALTER finished
Node A Node B
DELETE(108)
UPDATE(109)
Node C
INSERT(112)
SELECT(113)
UPDATE(114)
10
PROCESSLIST: DML before ALTER
DML node> select DB, COMMAND, TIME, STATE, INFO from information_schema.processlist WHERE DB=’sbtest’;
+--------+---------+------+---------------------------------------------------+-----------------------+
| DB | COMMAND | TIME | STATE | INFO |
+--------+---------+------+---------------------------------------------------+-----------------------+
| sbtest | Query | 1 | wsrep: initiating pre-commit for write set (2886) | COMMIT |
| sbtest | Query | 1 | wsrep: initiating pre-commit for write set (2888) | COMMIT |
| sbtest | Query | 1 | wsrep: initiating pre-commit for write set (2884) | COMMIT |
| sbtest | Query | 1 | updating | DELETE FROM sbtest1.. |
| sbtest | Query | 1 | wsrep: initiating pre-commit for write set (2887) | COMMIT |
| sbtest | Query | 0 | wsrep: initiating pre-commit for write set (2889) | COMMIT |
| sbtest | Query | 1 | wsrep: initiating pre-commit for write set (2885) | COMMIT |
| sbtest | Query | 1 | wsrep: pre-commit/certification passed (2883) | COMMIT |
+--------+---------+------+---------------------------------------------------+-----------------------+
8 rows in set (0.00 sec)
11
PROCESSLIST: SELECT before ALTER
SELECT node> select DB, COMMAND, TIME, STATE, INFO from information_schema.processlist
-> WHERE DB=’sbtest’;
+--------+---------+------+-------------------+---------------------------------------+
| DB | COMMAND | TIME | STATE | INFO |
+--------+---------+------+-------------------+---------------------------------------+
| sbtest | Query | 0 | statistics | SELECT pad FROM sbtest2 WHERE id=5009 |
| sbtest | Query | 0 | starting | SELECT pad FROM sbtest3 WHERE id=4951 |
| sbtest | Query | 0 | statistics | SELECT pad FROM sbtest4 WHERE id=4954 |
| sbtest | Query | 0 | System lock | SELECT pad FROM sbtest2 WHERE id=5351 |
| sbtest | Query | 0 | cleaning up | SELECT pad FROM sbtest2 WHERE id=4954 |
| sbtest | Sleep | 0 | | NULL |
| sbtest | Query | 0 | Sending to client | SELECT pad FROM sbtest1 WHERE id=4272 |
| sbtest | Query | 0 | closing tables | SELECT pad FROM sbtest4 WHERE id=4722 |
+--------+---------+------+-------------------+---------------------------------------+
8 rows in set (0.00 sec)
12
ALTER
DDL node> use ddltest;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
DDL node> alter table sbtest1 add key k1(c, k, pad);
Query OK, 0 rows affected (3 min 53.73 sec)
Records: 0 Duplicates: 0 Warnings: 0
13
PROCESSLIST: DML during ALTER
DML node> select DB, COMMAND, TIME, STATE, INFO from information_schema.processlist
-> WHERE DB in (’sbtest’,’ddltest’);
+---------+---------+------+---------------------------------------------------+----------------------+
| DB | COMMAND | TIME | STATE | |
+---------+---------+------+---------------------------------------------------+----------------------+
| sbtest | Query | 36 | wsrep: initiating pre-commit for write set (7886) | COMMIT |
| sbtest | Query | 37 | wsrep: initiating pre-commit for write set (7882) | COMMIT |
| sbtest | Query | 27 | wsrep: initiating pre-commit for write set (7887) | COMMIT |
| sbtest | Query | 27 | wsrep: initiating pre-commit for write set (7888) | COMMIT |
| sbtest | Query | 36 | wsrep: initiating pre-commit for write set (7885) | COMMIT |
| sbtest | Query | 37 | wsrep: initiating pre-commit for write set (7883) | COMMIT |
| sbtest | Query | 37 | wsrep: initiating pre-commit for write set (7884) | COMMIT |
| sbtest | Query | 10 | wsrep: initiating pre-commit for write set (7889) | COMMIT |
| ddltest | Sleep | 38 | altering table | alter table sbtest1. |
+---------+---------+------+---------------------------------------------------+----------------------+
9 rows in set (0.00 sec)
14
PROCESSLIST: SELECT during ALTER
SELECT node> select DB, COMMAND, TIME, STATE, INFO from information_schema.processlist
-> WHERE DB in (’sbtest’,’ddltest’);
+---------+---------+------+-------------------+-------------------------------------------+
| DB | COMMAND | TIME | STATE | |
+---------+---------+------+-------------------+-------------------------------------------+
| sbtest | Sleep | 0 | | NULL |
| sbtest | Sleep | 0 | | NULL |
| sbtest | Query | 0 | Sending to client | SELECT pad FROM sbtest4 WHERE id=4989 |
| sbtest | Sleep | 0 | | NULL |
| sbtest | Query | 0 | query end | SELECT pad FROM sbtest2 WHERE id=4961 |
| sbtest | Sleep | 0 | | NULL |
| sbtest | Sleep | 0 | | NULL |
| sbtest | Sleep | 0 | | NULL |
| ddltest | Sleep | 39 | altering table | alter table sbtest1 add key k1(c, k, pad) |
+---------+---------+------+-------------------+-------------------------------------------+
9 rows in set (0.14 sec)
15
TOI Advantages
• Data always consistent
• DDL applied to all nodes at the same time
• No failure due to schema inconsistency
16
TOI Disadvantages
• The whole cluster blocked
• For the duration of the entire DDL operation
• Schema upgrades replicated as a statement
• There is no guarantee that the ALTER succeed!
17
How to Perform Upgrade with TOI
• Schedule maintenance window
• Run DDL
• Cluster won’t be accessible until DDL ends
• SELECTs can continue
• wsrep sync wait != 1
18
When to Use TOI
• Quick DDL operations
19
When to Use TOI
• Quick DDL operations
• Creating new database objects
• CREATE DATABASE
• CREATE TABLE
19
When to Use TOI
• Quick DDL operations
• Creating new database objects
• Online operations which modify metadata only
• RENAME INDEX
• RENAME TABLE
• DROP INDEX
• ALGORITHM=INSTANT
Full list
19
RSU
Rolling Schema Upgrade (RSU)
• Variable wsrep OSU method
• Puts node into de-sync state
• For the duration of DDL
• Pauses Galera provider
• Schema can get out of sync!
21
User Responsibility
• Run DDL on the each node of the cluster
• Block read-write access that depend on DDL
• Until all nodes are in sync
• Make sure no write is performed to the table
• Until upgrade finishes on all nodes
• Failure makes cluster unrecoverable!
22
RSU Workflow
• User Action
• SET SESSION wsrep OSU method = ’RSU’;
• DDL
• Any other statement
• Node Operation
• Nothing
• Is wsrep OSU method set to RSU?
Yes Performs DDL
• Nothing
23
How Node Internally Executes DDL in RSU Mode
Does node have transactions in COMMIT mode?
24
How Node Internally Executes DDL in RSU Mode
Does node have transactions in COMMIT mode?
Yes Wait for 5 milliseconds
• wsrep RSU commit timeout (PXC only)
24
How Node Internally Executes DDL in RSU Mode
Does node have transactions in COMMIT mode?
Yes Wait for 5 milliseconds
• wsrep RSU commit timeout (PXC only)
Do transactions in the COMMIT mode still exist?
24
How Node Internally Executes DDL in RSU Mode
Does node have transactions in COMMIT mode?
Yes Wait for 5 milliseconds
• wsrep RSU commit timeout (PXC only)
Do transactions in the COMMIT mode still exist?
Yes Abort DDL
24
How Node Internally Executes DDL in RSU Mode
Does node have transactions in COMMIT mode?
No Put node into de-sync state
24
How Node Internally Executes DDL in RSU Mode
Does node have transactions in COMMIT mode?
No Put node into de-sync state
Pause write-set application
24
How Node Internally Executes DDL in RSU Mode
Does node have transactions in COMMIT mode?
No Put node into de-sync state
Pause write-set application
Execute DDL
24
How Node Internally Executes DDL in RSU Mode
Does node have transactions in COMMIT mode?
No Put node into de-sync state
Pause write-set application
Execute DDL
Bring the node back to the cluster
24
How Node Internally Executes DDL in RSU Mode
Does node have transactions in COMMIT mode?
No Put node into de-sync state
Pause write-set application
Execute DDL
Bring the node back to the cluster
Synchronize
24
RSU: Locking
• Not avoidable
• Updates to all objects on the node in RSU mode
must finish before the operation
• Failure aborts DDL
25
RSU Advantages
• Cluster remains functional
• Schedule long-running ALTER
• In the best time possible
26
RSU Disadvantages
• No checks for data and schema consistency
• This is your responsibility!
27
RSU Disadvantages
• No checks for data and schema consistency
• All writes must be stopped on the affected node
• Otherwise DDL fails with an error
27
RSU Disadvantages
• No checks for data and schema consistency
• All writes must be stopped on the affected node
• gcache should be big enough to hold changes
• Made while DDL was running
• Failure will cause SST when node re-joins cluster
• All schema changes will be lost
27
RSU Disadvantages
• No checks for data and schema consistency
• All writes must be stopped on the affected node
• gcache should be big enough to hold changes
• Any error can make cluster dysfunctional
27
RSU Disadvantages
• No checks for data and schema consistency
• All writes must be stopped on the affected node
• gcache should be big enough to hold changes
• Any error can make cluster dysfunctional
• Affected table must be offline
• Until the schema upgrade is done on all nodes
• Unless this is schema-compatible change
27
How to Use RSU
• Make sure gcache is big enough
• Must hold all updates while DDL is in progress
28
How to Use RSU
• Make sure gcache is big enough
• Must hold all updates while DDL is in progress
• Block all writes to the table/schema
28
How to Use RSU
Choose an ”upgrading node”
28
How to Use RSU
Choose an ”upgrading node”
Block all write requests to this node
28
How to Use RSU
Choose an ”upgrading node”
Block all write requests to this node
SET SESSION wsrep OSU method = ’RSU’;
28
How to Use RSU
Choose an ”upgrading node”
Block all write requests to this node
SET SESSION wsrep OSU method = ’RSU’;
Perform DDL in the same session
28
How to Use RSU
Choose an ”upgrading node”
Block all write requests to this node
SET SESSION wsrep OSU method = ’RSU’;
Perform DDL in the same session
SET SESSION wsrep OSU method = ’TOI’;
28
How to Use RSU
Choose an ”upgrading node”
Block all write requests to this node
SET SESSION wsrep OSU method = ’RSU’;
Perform DDL in the same session
SET SESSION wsrep OSU method = ’TOI’;
Re-enable writes
28
How to Use RSU
Choose an ”upgrading node”
Block all write requests to this node
SET SESSION wsrep OSU method = ’RSU’;
Perform DDL in the same session
SET SESSION wsrep OSU method = ’TOI’;
Re-enable writes
Repeat for other nodes
28
pt-online-schema-change (pt-osc)
pt-online-schema-change (pt-osc)
• A tool, performing non-blocking upgrades
• With TOI
30
pt-online-schema-change (pt-osc)
• A tool, performing non-blocking upgrades
• Creates a copy of table with altered definition
30
pt-online-schema-change (pt-osc)
• A tool, performing non-blocking upgrades
• Creates a copy of table with altered definition
• Creates triggers which will copy modified rows
30
pt-online-schema-change (pt-osc)
• A tool, performing non-blocking upgrades
• Creates a copy of table with altered definition
• Creates triggers which will copy modified rows
• Starts copying data in chunks
• Absolutely under control
• Can be paused or stopped
–max-flow-ctl
30
pt-online-schema-change (pt-osc)
• A tool, performing non-blocking upgrades
• Creates a copy of table with altered definition
• Creates triggers which will copy modified rows
• Starts copying data in chunks
• All rows already in the table are copied in chunks
• Newly modified rows are copied using triggers
30
pt-online-schema-change (pt-osc)
• A tool, performing non-blocking upgrades
• Creates a copy of table with altered definition
• Creates triggers which will copy modified rows
• Starts copying data in chunks
• Once copy is complete, drops the table
30
pt-online-schema-change (pt-osc)
• A tool, performing non-blocking upgrades
• Creates a copy of table with altered definition
• Creates triggers which will copy modified rows
• Starts copying data in chunks
• Once copy is complete, drops the table
• Renames the copy into the original table name
30
pt-osc Advantages
• DDL is safe and non-blocking
31
pt-osc Disadvantages
• Works only with InnoDB tables
• Increases IO load even for inplace operations
• Conflicts with already existing triggers
• Unless you use PXC >= 5.7
• Foreign keys updates are not effectively safe
32
How to Use pt-osc
• Study pt-osc options
• --max-flow-ctl
• Set appropriate limits
• Make sure wsrep OSU method is TOI
• Run pt-osc
33
Which Method to Use?
Will DDL be fast?
• CREATE DATABASE
• CREATE TABLE
• DROP INDEX
• Any ALTER on small tables
• Other
34
Which Method to Use?
Will DDL be fast?
Yes Use TOI
34
Which Method to Use?
Will DDL be fast?
Yes Use TOI
No Evaluate if you can use pt-osc
• Operation on the InnoDB table
• Table has no triggers or PXC >= 5.7
• Table is not referenced by a foreign key
• You can tolerate increased IO
34
Which Method to Use?
Will DDL be fast?
Yes Use TOI
No Evaluate if you can use pt-osc
Yes Use pt-osc
34
Which Method to Use?
Will DDL be fast?
Yes Use TOI
No Evaluate if you can use pt-osc
Yes Use pt-osc
No Use RSU
• Stop all write traffic on the node
• Stop all write traffic to the modified table
• Make sure to upgrade on all nodes
34
Conclusion
• Use TOI whenever possible
• Then use pt-osc
• RSU is a last resort
35
More information
Galera Cluster
Percona XtraDB Cluster
MariaDB Galera Cluster
pt-online-schema-change
36
Thank you!
www.slideshare.net/SvetaSmirnova
twitter.com/svetsmirnova
github.com/svetasmirnova
37

More Related Content

Similar to How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster

Training Slides: Advanced 304: Upgrading From Native MySQL Replication To Tun...
Training Slides: Advanced 304: Upgrading From Native MySQL Replication To Tun...Training Slides: Advanced 304: Upgrading From Native MySQL Replication To Tun...
Training Slides: Advanced 304: Upgrading From Native MySQL Replication To Tun...Continuent
 
Modern solutions for modern database load: improvements in the latest MariaDB...
Modern solutions for modern database load: improvements in the latest MariaDB...Modern solutions for modern database load: improvements in the latest MariaDB...
Modern solutions for modern database load: improvements in the latest MariaDB...Sveta Smirnova
 
MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527Saewoong Lee
 
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...Continuent
 
Percona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuningPercona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuningSergey Petrunya
 
Strategic Autovacuum
Strategic AutovacuumStrategic Autovacuum
Strategic AutovacuumScott Mead
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingSveta Smirnova
 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenNETWAYS
 
16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboardsDenis Ristic
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)Dave Stokes
 
Basic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsBasic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsSveta Smirnova
 
Streaming ETL - from RDBMS to Dashboard with KSQL
Streaming ETL - from RDBMS to Dashboard with KSQLStreaming ETL - from RDBMS to Dashboard with KSQL
Streaming ETL - from RDBMS to Dashboard with KSQLBjoern Rost
 
Top 10 tips for Oracle performance
Top 10 tips for Oracle performanceTop 10 tips for Oracle performance
Top 10 tips for Oracle performanceGuy Harrison
 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Tesora
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionSveta Smirnova
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)Jean-François Gagné
 
Developers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman OracleDevelopers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman OraclemCloud
 

Similar to How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster (20)

Training Slides: Advanced 304: Upgrading From Native MySQL Replication To Tun...
Training Slides: Advanced 304: Upgrading From Native MySQL Replication To Tun...Training Slides: Advanced 304: Upgrading From Native MySQL Replication To Tun...
Training Slides: Advanced 304: Upgrading From Native MySQL Replication To Tun...
 
Modern solutions for modern database load: improvements in the latest MariaDB...
Modern solutions for modern database load: improvements in the latest MariaDB...Modern solutions for modern database load: improvements in the latest MariaDB...
Modern solutions for modern database load: improvements in the latest MariaDB...
 
MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527
 
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...
 
Percona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuningPercona live-2012-optimizer-tuning
Percona live-2012-optimizer-tuning
 
Strategic Autovacuum
Strategic AutovacuumStrategic Autovacuum
Strategic Autovacuum
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert VanderkelenOSMC 2008 | Monitoring MySQL by Geert Vanderkelen
OSMC 2008 | Monitoring MySQL by Geert Vanderkelen
 
16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards
 
Mysql56 replication
Mysql56 replicationMysql56 replication
Mysql56 replication
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
 
Basic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsBasic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database Administrators
 
Streaming ETL - from RDBMS to Dashboard with KSQL
Streaming ETL - from RDBMS to Dashboard with KSQLStreaming ETL - from RDBMS to Dashboard with KSQL
Streaming ETL - from RDBMS to Dashboard with KSQL
 
Top 10 tips for Oracle performance
Top 10 tips for Oracle performanceTop 10 tips for Oracle performance
Top 10 tips for Oracle performance
 
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
Percona Live 4/15/15: Transparent sharding database virtualization engine (DVE)
 
DPC Tutorial
DPC TutorialDPC Tutorial
DPC Tutorial
 
MySQLinsanity
MySQLinsanityMySQLinsanity
MySQLinsanity
 
New features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in actionNew features in Performance Schema 5.7 in action
New features in Performance Schema 5.7 in action
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
 
Developers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman OracleDevelopers' mDay 2017. - Bogdan Kecman Oracle
Developers' mDay 2017. - Bogdan Kecman Oracle
 

More from Sveta Smirnova

MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?Sveta Smirnova
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringSveta Smirnova
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveSveta Smirnova
 
MySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for DevelopersMySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for DevelopersSveta Smirnova
 
MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOpsSveta Smirnova
 
MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговMySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговSveta Smirnova
 
MySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your BusinessMySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your BusinessSveta Smirnova
 
Introduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sIntroduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sSveta Smirnova
 
Производительность MySQL для DevOps
 Производительность MySQL для DevOps Производительность MySQL для DevOps
Производительность MySQL для DevOpsSveta Smirnova
 
MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOpsSveta Smirnova
 
How to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tearsHow to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tearsSveta Smirnova
 
How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?Sveta Smirnova
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaСовременному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaSveta Smirnova
 
How Safe is Asynchronous Master-Master Setup?
 How Safe is Asynchronous Master-Master Setup? How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?Sveta Smirnova
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sIntroduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sSveta Smirnova
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Sveta Smirnova
 
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...Sveta Smirnova
 
Что нужно знать о трёх топовых фичах MySQL
Что нужно знать  о трёх топовых фичах  MySQLЧто нужно знать  о трёх топовых фичах  MySQL
Что нужно знать о трёх топовых фичах MySQLSveta Smirnova
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Sveta Smirnova
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in ActionSveta Smirnova
 

More from Sveta Smirnova (20)

MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
MySQL 2024: Зачем переходить на MySQL 8, если в 5.х всё устраивает?
 
Database in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and MonitoringDatabase in Kubernetes: Diagnostics and Monitoring
Database in Kubernetes: Diagnostics and Monitoring
 
MySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to HaveMySQL Database Monitoring: Must, Good and Nice to Have
MySQL Database Monitoring: Must, Good and Nice to Have
 
MySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for DevelopersMySQL Cookbook: Recipes for Developers
MySQL Cookbook: Recipes for Developers
 
MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOps
 
MySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации баговMySQL Test Framework для поддержки клиентов и верификации багов
MySQL Test Framework для поддержки клиентов и верификации багов
 
MySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your BusinessMySQL Cookbook: Recipes for Your Business
MySQL Cookbook: Recipes for Your Business
 
Introduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]sIntroduction into MySQL Query Tuning for Dev[Op]s
Introduction into MySQL Query Tuning for Dev[Op]s
 
Производительность MySQL для DevOps
 Производительность MySQL для DevOps Производительность MySQL для DevOps
Производительность MySQL для DevOps
 
MySQL Performance for DevOps
MySQL Performance for DevOpsMySQL Performance for DevOps
MySQL Performance for DevOps
 
How to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tearsHow to migrate from MySQL to MariaDB without tears
How to migrate from MySQL to MariaDB without tears
 
How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
 
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения PerconaСовременному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
Современному хайлоду - современные решения: MySQL 8.0 и улучшения Percona
 
How Safe is Asynchronous Master-Master Setup?
 How Safe is Asynchronous Master-Master Setup? How Safe is Asynchronous Master-Master Setup?
How Safe is Asynchronous Master-Master Setup?
 
Introduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]sIntroduction to MySQL Query Tuning for Dev[Op]s
Introduction to MySQL Query Tuning for Dev[Op]s
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?
 
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
A Billion Goods in a Few Categories: When Optimizer Histograms Help and When ...
 
Что нужно знать о трёх топовых фичах MySQL
Что нужно знать  о трёх топовых фичах  MySQLЧто нужно знать  о трёх топовых фичах  MySQL
Что нужно знать о трёх топовых фичах MySQL
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?
 
MySQL Performance Schema in Action
MySQL Performance Schema in ActionMySQL Performance Schema in Action
MySQL Performance Schema in Action
 

Recently uploaded

Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 

Recently uploaded (20)

Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 

How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster

  • 1. How to Avoid Pitfalls in Schema Upgrade with Percona XtraDB Cluster Sveta Smirnova Percona
  • 2. Sveta Smirnova • MySQL Support engineer • Author of • MySQL Troubleshooting • JSON UDF functions • FILTER clause for MySQL • Speaker • Percona Live, OOW, Fosdem, DevConf, HighLoad... 2
  • 4. Introduction • Galera Replication Library • Provides synchronous replication for MySQL 4
  • 5. Introduction • Galera Replication Library • Provides synchronous replication for MySQL • Galera Clusters Percona XtraDB Cluster MariaDB Galera Cluster Galera Cluster for MySQL 4
  • 6. How Galera works • Data modification happens on a node • Optimistic locking control 5
  • 7. How Galera works • Data modification happens on a node • Optimistic locking control • While a transaction is in progress • Writes are applied locally • Same as for standalone server 5
  • 8. How Galera works • Data modification happens on a node • Optimistic locking control • While a transaction is in progress • At the COMMIT time • Broadcasts write set for the cluster • Waits confirmation of the successful update From all other nodes Yes Commits transaction locally No Rollbacks transaction 5
  • 9. Data Updates • Committed on all nodes or nowhere • Safe 6
  • 10. Challenges of DDL • Replicated independently from storage engine 7
  • 11. Challenges of DDL • Replicated independently from storage engine • Changes may affect query results • Adding/removal of UNIQUE keys • Adding/removal columns • Changing column definition 7
  • 12. Challenges of DDL • Replicated independently from storage engine • Changes may affect query results • Modification can happen on any node • The schema must be upgraded before DML • There is no way to rollback schema upgrade • MDLs are set only on one node Not across the cluster Not possible to rely on them for all nodes Additional control required 7
  • 13. TOI
  • 14. Total Order Isolation (TOI) • DDL changes are replicated in the same order • Regarding other transactions • All nodes are in the absolutely same state • At any point of time 9
  • 15. TOI: Illustration • 3-nodes cluster • Node A • Node B • Node C 10
  • 16. TOI: Illustration • Initial state Node A INSERT(103) UPDATE(104) ALTER(105) Node B UPDATE(101) INSERT(102) DELETE(108) UPDATE(109) Node C SELECT(100) INSERT(112) SELECT(113) UPDATE(114) 10
  • 17. TOI: Illustration • Queries status Node A INSERT(103) UPDATE(104) ALTER(105) Node B UPDATE(101) INSERT(102) DELETE(108) UPDATE(109) Node C SELECT(100) INSERT(112) SELECT(113) UPDATE(114) 10
  • 18. TOI: Illustration • ALTER in progress Node A ALTER(105) Node B DELETE(108) UPDATE(109) Node C INSERT(112) SELECT(113) UPDATE(114) 10
  • 19. TOI: Illustration • ALTER finished Node A Node B DELETE(108) UPDATE(109) Node C INSERT(112) SELECT(113) UPDATE(114) 10
  • 20. PROCESSLIST: DML before ALTER DML node> select DB, COMMAND, TIME, STATE, INFO from information_schema.processlist WHERE DB=’sbtest’; +--------+---------+------+---------------------------------------------------+-----------------------+ | DB | COMMAND | TIME | STATE | INFO | +--------+---------+------+---------------------------------------------------+-----------------------+ | sbtest | Query | 1 | wsrep: initiating pre-commit for write set (2886) | COMMIT | | sbtest | Query | 1 | wsrep: initiating pre-commit for write set (2888) | COMMIT | | sbtest | Query | 1 | wsrep: initiating pre-commit for write set (2884) | COMMIT | | sbtest | Query | 1 | updating | DELETE FROM sbtest1.. | | sbtest | Query | 1 | wsrep: initiating pre-commit for write set (2887) | COMMIT | | sbtest | Query | 0 | wsrep: initiating pre-commit for write set (2889) | COMMIT | | sbtest | Query | 1 | wsrep: initiating pre-commit for write set (2885) | COMMIT | | sbtest | Query | 1 | wsrep: pre-commit/certification passed (2883) | COMMIT | +--------+---------+------+---------------------------------------------------+-----------------------+ 8 rows in set (0.00 sec) 11
  • 21. PROCESSLIST: SELECT before ALTER SELECT node> select DB, COMMAND, TIME, STATE, INFO from information_schema.processlist -> WHERE DB=’sbtest’; +--------+---------+------+-------------------+---------------------------------------+ | DB | COMMAND | TIME | STATE | INFO | +--------+---------+------+-------------------+---------------------------------------+ | sbtest | Query | 0 | statistics | SELECT pad FROM sbtest2 WHERE id=5009 | | sbtest | Query | 0 | starting | SELECT pad FROM sbtest3 WHERE id=4951 | | sbtest | Query | 0 | statistics | SELECT pad FROM sbtest4 WHERE id=4954 | | sbtest | Query | 0 | System lock | SELECT pad FROM sbtest2 WHERE id=5351 | | sbtest | Query | 0 | cleaning up | SELECT pad FROM sbtest2 WHERE id=4954 | | sbtest | Sleep | 0 | | NULL | | sbtest | Query | 0 | Sending to client | SELECT pad FROM sbtest1 WHERE id=4272 | | sbtest | Query | 0 | closing tables | SELECT pad FROM sbtest4 WHERE id=4722 | +--------+---------+------+-------------------+---------------------------------------+ 8 rows in set (0.00 sec) 12
  • 22. ALTER DDL node> use ddltest; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A DDL node> alter table sbtest1 add key k1(c, k, pad); Query OK, 0 rows affected (3 min 53.73 sec) Records: 0 Duplicates: 0 Warnings: 0 13
  • 23. PROCESSLIST: DML during ALTER DML node> select DB, COMMAND, TIME, STATE, INFO from information_schema.processlist -> WHERE DB in (’sbtest’,’ddltest’); +---------+---------+------+---------------------------------------------------+----------------------+ | DB | COMMAND | TIME | STATE | | +---------+---------+------+---------------------------------------------------+----------------------+ | sbtest | Query | 36 | wsrep: initiating pre-commit for write set (7886) | COMMIT | | sbtest | Query | 37 | wsrep: initiating pre-commit for write set (7882) | COMMIT | | sbtest | Query | 27 | wsrep: initiating pre-commit for write set (7887) | COMMIT | | sbtest | Query | 27 | wsrep: initiating pre-commit for write set (7888) | COMMIT | | sbtest | Query | 36 | wsrep: initiating pre-commit for write set (7885) | COMMIT | | sbtest | Query | 37 | wsrep: initiating pre-commit for write set (7883) | COMMIT | | sbtest | Query | 37 | wsrep: initiating pre-commit for write set (7884) | COMMIT | | sbtest | Query | 10 | wsrep: initiating pre-commit for write set (7889) | COMMIT | | ddltest | Sleep | 38 | altering table | alter table sbtest1. | +---------+---------+------+---------------------------------------------------+----------------------+ 9 rows in set (0.00 sec) 14
  • 24. PROCESSLIST: SELECT during ALTER SELECT node> select DB, COMMAND, TIME, STATE, INFO from information_schema.processlist -> WHERE DB in (’sbtest’,’ddltest’); +---------+---------+------+-------------------+-------------------------------------------+ | DB | COMMAND | TIME | STATE | | +---------+---------+------+-------------------+-------------------------------------------+ | sbtest | Sleep | 0 | | NULL | | sbtest | Sleep | 0 | | NULL | | sbtest | Query | 0 | Sending to client | SELECT pad FROM sbtest4 WHERE id=4989 | | sbtest | Sleep | 0 | | NULL | | sbtest | Query | 0 | query end | SELECT pad FROM sbtest2 WHERE id=4961 | | sbtest | Sleep | 0 | | NULL | | sbtest | Sleep | 0 | | NULL | | sbtest | Sleep | 0 | | NULL | | ddltest | Sleep | 39 | altering table | alter table sbtest1 add key k1(c, k, pad) | +---------+---------+------+-------------------+-------------------------------------------+ 9 rows in set (0.14 sec) 15
  • 25. TOI Advantages • Data always consistent • DDL applied to all nodes at the same time • No failure due to schema inconsistency 16
  • 26. TOI Disadvantages • The whole cluster blocked • For the duration of the entire DDL operation • Schema upgrades replicated as a statement • There is no guarantee that the ALTER succeed! 17
  • 27. How to Perform Upgrade with TOI • Schedule maintenance window • Run DDL • Cluster won’t be accessible until DDL ends • SELECTs can continue • wsrep sync wait != 1 18
  • 28. When to Use TOI • Quick DDL operations 19
  • 29. When to Use TOI • Quick DDL operations • Creating new database objects • CREATE DATABASE • CREATE TABLE 19
  • 30. When to Use TOI • Quick DDL operations • Creating new database objects • Online operations which modify metadata only • RENAME INDEX • RENAME TABLE • DROP INDEX • ALGORITHM=INSTANT Full list 19
  • 31. RSU
  • 32. Rolling Schema Upgrade (RSU) • Variable wsrep OSU method • Puts node into de-sync state • For the duration of DDL • Pauses Galera provider • Schema can get out of sync! 21
  • 33. User Responsibility • Run DDL on the each node of the cluster • Block read-write access that depend on DDL • Until all nodes are in sync • Make sure no write is performed to the table • Until upgrade finishes on all nodes • Failure makes cluster unrecoverable! 22
  • 34. RSU Workflow • User Action • SET SESSION wsrep OSU method = ’RSU’; • DDL • Any other statement • Node Operation • Nothing • Is wsrep OSU method set to RSU? Yes Performs DDL • Nothing 23
  • 35. How Node Internally Executes DDL in RSU Mode Does node have transactions in COMMIT mode? 24
  • 36. How Node Internally Executes DDL in RSU Mode Does node have transactions in COMMIT mode? Yes Wait for 5 milliseconds • wsrep RSU commit timeout (PXC only) 24
  • 37. How Node Internally Executes DDL in RSU Mode Does node have transactions in COMMIT mode? Yes Wait for 5 milliseconds • wsrep RSU commit timeout (PXC only) Do transactions in the COMMIT mode still exist? 24
  • 38. How Node Internally Executes DDL in RSU Mode Does node have transactions in COMMIT mode? Yes Wait for 5 milliseconds • wsrep RSU commit timeout (PXC only) Do transactions in the COMMIT mode still exist? Yes Abort DDL 24
  • 39. How Node Internally Executes DDL in RSU Mode Does node have transactions in COMMIT mode? No Put node into de-sync state 24
  • 40. How Node Internally Executes DDL in RSU Mode Does node have transactions in COMMIT mode? No Put node into de-sync state Pause write-set application 24
  • 41. How Node Internally Executes DDL in RSU Mode Does node have transactions in COMMIT mode? No Put node into de-sync state Pause write-set application Execute DDL 24
  • 42. How Node Internally Executes DDL in RSU Mode Does node have transactions in COMMIT mode? No Put node into de-sync state Pause write-set application Execute DDL Bring the node back to the cluster 24
  • 43. How Node Internally Executes DDL in RSU Mode Does node have transactions in COMMIT mode? No Put node into de-sync state Pause write-set application Execute DDL Bring the node back to the cluster Synchronize 24
  • 44. RSU: Locking • Not avoidable • Updates to all objects on the node in RSU mode must finish before the operation • Failure aborts DDL 25
  • 45. RSU Advantages • Cluster remains functional • Schedule long-running ALTER • In the best time possible 26
  • 46. RSU Disadvantages • No checks for data and schema consistency • This is your responsibility! 27
  • 47. RSU Disadvantages • No checks for data and schema consistency • All writes must be stopped on the affected node • Otherwise DDL fails with an error 27
  • 48. RSU Disadvantages • No checks for data and schema consistency • All writes must be stopped on the affected node • gcache should be big enough to hold changes • Made while DDL was running • Failure will cause SST when node re-joins cluster • All schema changes will be lost 27
  • 49. RSU Disadvantages • No checks for data and schema consistency • All writes must be stopped on the affected node • gcache should be big enough to hold changes • Any error can make cluster dysfunctional 27
  • 50. RSU Disadvantages • No checks for data and schema consistency • All writes must be stopped on the affected node • gcache should be big enough to hold changes • Any error can make cluster dysfunctional • Affected table must be offline • Until the schema upgrade is done on all nodes • Unless this is schema-compatible change 27
  • 51. How to Use RSU • Make sure gcache is big enough • Must hold all updates while DDL is in progress 28
  • 52. How to Use RSU • Make sure gcache is big enough • Must hold all updates while DDL is in progress • Block all writes to the table/schema 28
  • 53. How to Use RSU Choose an ”upgrading node” 28
  • 54. How to Use RSU Choose an ”upgrading node” Block all write requests to this node 28
  • 55. How to Use RSU Choose an ”upgrading node” Block all write requests to this node SET SESSION wsrep OSU method = ’RSU’; 28
  • 56. How to Use RSU Choose an ”upgrading node” Block all write requests to this node SET SESSION wsrep OSU method = ’RSU’; Perform DDL in the same session 28
  • 57. How to Use RSU Choose an ”upgrading node” Block all write requests to this node SET SESSION wsrep OSU method = ’RSU’; Perform DDL in the same session SET SESSION wsrep OSU method = ’TOI’; 28
  • 58. How to Use RSU Choose an ”upgrading node” Block all write requests to this node SET SESSION wsrep OSU method = ’RSU’; Perform DDL in the same session SET SESSION wsrep OSU method = ’TOI’; Re-enable writes 28
  • 59. How to Use RSU Choose an ”upgrading node” Block all write requests to this node SET SESSION wsrep OSU method = ’RSU’; Perform DDL in the same session SET SESSION wsrep OSU method = ’TOI’; Re-enable writes Repeat for other nodes 28
  • 61. pt-online-schema-change (pt-osc) • A tool, performing non-blocking upgrades • With TOI 30
  • 62. pt-online-schema-change (pt-osc) • A tool, performing non-blocking upgrades • Creates a copy of table with altered definition 30
  • 63. pt-online-schema-change (pt-osc) • A tool, performing non-blocking upgrades • Creates a copy of table with altered definition • Creates triggers which will copy modified rows 30
  • 64. pt-online-schema-change (pt-osc) • A tool, performing non-blocking upgrades • Creates a copy of table with altered definition • Creates triggers which will copy modified rows • Starts copying data in chunks • Absolutely under control • Can be paused or stopped –max-flow-ctl 30
  • 65. pt-online-schema-change (pt-osc) • A tool, performing non-blocking upgrades • Creates a copy of table with altered definition • Creates triggers which will copy modified rows • Starts copying data in chunks • All rows already in the table are copied in chunks • Newly modified rows are copied using triggers 30
  • 66. pt-online-schema-change (pt-osc) • A tool, performing non-blocking upgrades • Creates a copy of table with altered definition • Creates triggers which will copy modified rows • Starts copying data in chunks • Once copy is complete, drops the table 30
  • 67. pt-online-schema-change (pt-osc) • A tool, performing non-blocking upgrades • Creates a copy of table with altered definition • Creates triggers which will copy modified rows • Starts copying data in chunks • Once copy is complete, drops the table • Renames the copy into the original table name 30
  • 68. pt-osc Advantages • DDL is safe and non-blocking 31
  • 69. pt-osc Disadvantages • Works only with InnoDB tables • Increases IO load even for inplace operations • Conflicts with already existing triggers • Unless you use PXC >= 5.7 • Foreign keys updates are not effectively safe 32
  • 70. How to Use pt-osc • Study pt-osc options • --max-flow-ctl • Set appropriate limits • Make sure wsrep OSU method is TOI • Run pt-osc 33
  • 71. Which Method to Use? Will DDL be fast? • CREATE DATABASE • CREATE TABLE • DROP INDEX • Any ALTER on small tables • Other 34
  • 72. Which Method to Use? Will DDL be fast? Yes Use TOI 34
  • 73. Which Method to Use? Will DDL be fast? Yes Use TOI No Evaluate if you can use pt-osc • Operation on the InnoDB table • Table has no triggers or PXC >= 5.7 • Table is not referenced by a foreign key • You can tolerate increased IO 34
  • 74. Which Method to Use? Will DDL be fast? Yes Use TOI No Evaluate if you can use pt-osc Yes Use pt-osc 34
  • 75. Which Method to Use? Will DDL be fast? Yes Use TOI No Evaluate if you can use pt-osc Yes Use pt-osc No Use RSU • Stop all write traffic on the node • Stop all write traffic to the modified table • Make sure to upgrade on all nodes 34
  • 76. Conclusion • Use TOI whenever possible • Then use pt-osc • RSU is a last resort 35
  • 77. More information Galera Cluster Percona XtraDB Cluster MariaDB Galera Cluster pt-online-schema-change 36