SlideShare a Scribd company logo
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 121
Insert Picture Here
MySQL Cluster schema
management
Frazer Clement
MySQL Cluster Technical lead
frazer.clement@oracle.com
messagepassing.blogspot.com
November 2014
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.2
MySQLD
●
Each MySQLD maintains independent schema information in Data
Directory structure, and on disk .frm files
●
MySQLD stores SQL level schema information, actual creation of
tables, indices, storage is delegated to the storage engine (SE).
●
ha_ndbcluster the Ndb 'storage engine' layer uses a 'Global Schema
Lock' (GSL) and 'Schema distribution' via the mysql.ndb_schema table to
synchronise schemas across all MySQLDs in a cluster.
●
MySQLD has the concept of certain schema operations (DDL) being
'online' or 'in place' as opposed to 'offline' or 'copying'.
●
Generally any schema change can be done offline/copying, and only a
(growing) subset can be done online / inplace.
Schema management Offline / copying schema changes commonly
require at least 2*table storage to complete
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3
MySQLD
For offline / copying changes :
●
Much of the work is done by MySQLD :
Create table sql#xxx with new schema, Scan old table copying and
reformatting rows, Rename table name to sql#yyy, sql#xxx to table
name, drop table sql#yyy.
●
MySQLD will take protective table locks on the MySQLD where the
DDL is running, but these have no effect on queries or DML from NdbApi
clients or other MySQLDs.
●
The scan/copy part of offline schema change is not consistent w.r.t.
ongoing updates, so they must be stopped during the schema change.
Schema management Offline / copying schema changes can be
effectively 'online' if they are performed at a
backup site, and replication is used.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4
MySQLD
●
For online/inplace changes most of the work is delegated to the SE as
it is usually very implementation specific.
●
Sometimes MySQLD takes more conservative locks than necessary
(e.g. table locks) while online schema operations are running. These
can lock out concurrent access on the MySQLD where the DDL is
running. This is confusing and limiting, but it is still possible to run
queries and DML via NdbApi and other MySQLDs.
Schema management
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.5
Ndb
●
Ndb has its own Data dictionary (see ndb_show_tables, ndb_desc
etc)
●
Data dictionary is distributed, transactional etc, independent of
MySQLD view of schema
●
Transactions (since 7.0) ensure clean rollback if participants fail or
resources are exhausted during a schema operation.
●
Ndb schema objects are versioned with a Major and Minor version.
Compatible (online) changes only increment the Minor part of the
version.
●
For tables, the Ndb data dictionary contains the table's .frm content as
a Blob. This allows the SE to 'create' the tables on newly started / re-
initialised MySQLD nodes.
Schema management
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.6
Currently supported Ndb online schema operations
●
Add index
●
Drop index
●
Add column (at end of row)
●
Reorganise partitions
Add index uses an Ndb-internal 'live copy' mechanism (similar to the
node recovery) to build an index while the indexed data is changing.
Add column makes use of 'Dynamic columns' inside LDM to add a
column by only changing table metadata- no need to scan/modify every
row.
Reorg uses triggers and special row markers.
Schema management
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.7
Issues in online schema change
●
Handling ongoing write activity
●
Minimising transient storage increase.
●
Amount of data involved if every row must be touched
●
Re-optimising storage if data is removed.
●
Compatible and non-compatible changes for existing clients
●
Dependencies between schema and clients
●
Replication
●
Backup and Restore
Schema management
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.8
Schema object versions + NdbApi
●
Visible via ndb_show_tables (and ndbinfo in 7.4+)
●
Online change (e.g. add column) increments minor version
●
Offline change (e.g. drop column) increments major version (or
changes schema object id)
●
NdbApi clients have a schema object cache, where each object is
versioned.
●
NdbApi operations carry the schema object versions they were defined
against.
●
If the data node's version differs only in the minor version, the operation
can proceed. If it differs in major version, it is rejected.
●
On schema object version error, clients will invalidate their local objects
and re-fetch.
Schema management
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.9
Schema object versions + NdbApi
●
This mechanism allows online schema upgrades where clients can
lazily update their schema object caches.
MySQLD approach
MySQLD is involved in all schema changes via schema distribution.
Schema changes are logically made to occur on epoch boundaries.
MySQLD controls (its) schema object invalidation.
MySQLD controls the schema used for Binlogging at any point in time,
Schema management
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.10
Replication
●
Replication supports a set of attribute (column) type promotions and
demotions, as well as different numbers of columns at Master + Slave.
●
This allows different schemas at Master and Slave
Backup + Restore
ndb_restore supports a set of column type promotions and demotions
designed to mirror those supported by replication. This allows B+R on a
slave with different cluster to be a schema change mechanism and
ensures that the worst-case recovery mechanism (B+R) works even
when schemas are misaligned between replicas.
Schema management

More Related Content

PDF
MySQL Cluster page management (2014)
PDF
Breakthrough performance with MySQL Cluster (2012)
PDF
MariaDB: Connect Storage Engine
PDF
The Great Debate: PostgreSQL vs MySQL
 
PPTX
Introduction to NuoDB
PDF
Elephants vs. Dolphins: Comparing PostgreSQL and MySQL for use in the DoD
PPT
No SQL and MongoDB - Hyderabad Scalability Meetup
PDF
Postgres_9.0 vs MySQL_5.5
MySQL Cluster page management (2014)
Breakthrough performance with MySQL Cluster (2012)
MariaDB: Connect Storage Engine
The Great Debate: PostgreSQL vs MySQL
 
Introduction to NuoDB
Elephants vs. Dolphins: Comparing PostgreSQL and MySQL for use in the DoD
No SQL and MongoDB - Hyderabad Scalability Meetup
Postgres_9.0 vs MySQL_5.5

What's hot (20)

PDF
2012 10 24_briefing room
PDF
MariaDB CONNECT Storage Engine
PDF
The Future of Distributed Databases
PDF
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
PDF
Architecture of exadata database machine – Part II
PDF
MySQL 5.5&5.6 new features summary
PDF
MySQL Cluster Local Checkpoint (LCP) evolution in 7.6 (2019)
PDF
Design Patterns for Distributed Non-Relational Databases
PDF
NoSQL databases
PDF
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
PPT
6 Data Modeling for NoSQL 2/2
PDF
MySQL For Oracle Developers
PDF
Triangle MySQL User Group MySQL Fabric Presentation Feb 12th, 2015
PDF
NoSQL and MySQL webinar - best of both worlds
PDF
In-memory Database and MySQL Cluster
PPTX
IN-MEMORY DATABASE SYSTEMS FOR BIG DATA MANAGEMENT.SAP HANA DATABASE.
PDF
Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014
ODP
Mysql For Developers
PPT
Mysql database
PDF
NoSQL Databases
2012 10 24_briefing room
MariaDB CONNECT Storage Engine
The Future of Distributed Databases
"Advanced MySQL 5 Tuning" by Michael Monty Widenius @ eLiberatica 2007
Architecture of exadata database machine – Part II
MySQL 5.5&5.6 new features summary
MySQL Cluster Local Checkpoint (LCP) evolution in 7.6 (2019)
Design Patterns for Distributed Non-Relational Databases
NoSQL databases
Connector/J Beyond JDBC: the X DevAPI for Java and MySQL as a Document Store
6 Data Modeling for NoSQL 2/2
MySQL For Oracle Developers
Triangle MySQL User Group MySQL Fabric Presentation Feb 12th, 2015
NoSQL and MySQL webinar - best of both worlds
In-memory Database and MySQL Cluster
IN-MEMORY DATABASE SYSTEMS FOR BIG DATA MANAGEMENT.SAP HANA DATABASE.
Scaling MySQl 1 to N Servers -- Los Angelese MySQL User Group Feb 2014
Mysql For Developers
Mysql database
NoSQL Databases
Ad

Similar to MySQL Cluster Schema management (2014) (20)

PDF
Metadata Synchronization in MySQL NDB Cluster 8.0
PDF
MySQL-InnoDB
PDF
Introduction to MySQL Cluster
PDF
MySQL Day Paris 2016 - MySQL as a Document Store
PPTX
A Step by Step Introduction to the MySQL Document Store
ODP
MySQL Cluster
PDF
MySQL Cluster 8.0 tutorial
PDF
MySQL NDB Cluster 8.0
ODP
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
PDF
MySQL Document Store
PDF
MySQL For Linux Sysadmins
PDF
Exploring mysql cluster 7.4
PDF
MySQL 8.0 Document Store - Discovery of a New World
PDF
MySQL Document Store (Oracle Code Warsaw 2018)
PDF
Ndb cluster 80_tpc_h
PDF
Ohio Linux Fest -- MySQL's NoSQL
PDF
NoSQL and MySQL
PDF
Collaborate 2012 - Administering MySQL for Oracle DBAs
PDF
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
PDF
MySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB Cluster
Metadata Synchronization in MySQL NDB Cluster 8.0
MySQL-InnoDB
Introduction to MySQL Cluster
MySQL Day Paris 2016 - MySQL as a Document Store
A Step by Step Introduction to the MySQL Document Store
MySQL Cluster
MySQL Cluster 8.0 tutorial
MySQL NDB Cluster 8.0
MySQL? Load? Clustering! Balancing! PECL/mysqlnd_ms 1.4
MySQL Document Store
MySQL For Linux Sysadmins
Exploring mysql cluster 7.4
MySQL 8.0 Document Store - Discovery of a New World
MySQL Document Store (Oracle Code Warsaw 2018)
Ndb cluster 80_tpc_h
Ohio Linux Fest -- MySQL's NoSQL
NoSQL and MySQL
Collaborate 2012 - Administering MySQL for Oracle DBAs
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL Day Paris 2016 - MySQL HA: InnoDB Cluster and NDB Cluster
Ad

Recently uploaded (20)

PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
L1 - Introduction to python Backend.pptx
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Transform Your Business with a Software ERP System
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
ai tools demonstartion for schools and inter college
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Nekopoi APK 2025 free lastest update
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
history of c programming in notes for students .pptx
PDF
Digital Strategies for Manufacturing Companies
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Upgrade and Innovation Strategies for SAP ERP Customers
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
L1 - Introduction to python Backend.pptx
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Transform Your Business with a Software ERP System
Operating system designcfffgfgggggggvggggggggg
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
ai tools demonstartion for schools and inter college
How to Choose the Right IT Partner for Your Business in Malaysia
Nekopoi APK 2025 free lastest update
wealthsignaloriginal-com-DS-text-... (1).pdf
Design an Analysis of Algorithms I-SECS-1021-03
Which alternative to Crystal Reports is best for small or large businesses.pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Odoo Companies in India – Driving Business Transformation.pdf
history of c programming in notes for students .pptx
Digital Strategies for Manufacturing Companies
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...

MySQL Cluster Schema management (2014)

  • 1. Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 121 Insert Picture Here MySQL Cluster schema management Frazer Clement MySQL Cluster Technical lead frazer.clement@oracle.com messagepassing.blogspot.com November 2014
  • 2. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.2 MySQLD ● Each MySQLD maintains independent schema information in Data Directory structure, and on disk .frm files ● MySQLD stores SQL level schema information, actual creation of tables, indices, storage is delegated to the storage engine (SE). ● ha_ndbcluster the Ndb 'storage engine' layer uses a 'Global Schema Lock' (GSL) and 'Schema distribution' via the mysql.ndb_schema table to synchronise schemas across all MySQLDs in a cluster. ● MySQLD has the concept of certain schema operations (DDL) being 'online' or 'in place' as opposed to 'offline' or 'copying'. ● Generally any schema change can be done offline/copying, and only a (growing) subset can be done online / inplace. Schema management Offline / copying schema changes commonly require at least 2*table storage to complete
  • 3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3 MySQLD For offline / copying changes : ● Much of the work is done by MySQLD : Create table sql#xxx with new schema, Scan old table copying and reformatting rows, Rename table name to sql#yyy, sql#xxx to table name, drop table sql#yyy. ● MySQLD will take protective table locks on the MySQLD where the DDL is running, but these have no effect on queries or DML from NdbApi clients or other MySQLDs. ● The scan/copy part of offline schema change is not consistent w.r.t. ongoing updates, so they must be stopped during the schema change. Schema management Offline / copying schema changes can be effectively 'online' if they are performed at a backup site, and replication is used.
  • 4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4 MySQLD ● For online/inplace changes most of the work is delegated to the SE as it is usually very implementation specific. ● Sometimes MySQLD takes more conservative locks than necessary (e.g. table locks) while online schema operations are running. These can lock out concurrent access on the MySQLD where the DDL is running. This is confusing and limiting, but it is still possible to run queries and DML via NdbApi and other MySQLDs. Schema management
  • 5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.5 Ndb ● Ndb has its own Data dictionary (see ndb_show_tables, ndb_desc etc) ● Data dictionary is distributed, transactional etc, independent of MySQLD view of schema ● Transactions (since 7.0) ensure clean rollback if participants fail or resources are exhausted during a schema operation. ● Ndb schema objects are versioned with a Major and Minor version. Compatible (online) changes only increment the Minor part of the version. ● For tables, the Ndb data dictionary contains the table's .frm content as a Blob. This allows the SE to 'create' the tables on newly started / re- initialised MySQLD nodes. Schema management
  • 6. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.6 Currently supported Ndb online schema operations ● Add index ● Drop index ● Add column (at end of row) ● Reorganise partitions Add index uses an Ndb-internal 'live copy' mechanism (similar to the node recovery) to build an index while the indexed data is changing. Add column makes use of 'Dynamic columns' inside LDM to add a column by only changing table metadata- no need to scan/modify every row. Reorg uses triggers and special row markers. Schema management
  • 7. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.7 Issues in online schema change ● Handling ongoing write activity ● Minimising transient storage increase. ● Amount of data involved if every row must be touched ● Re-optimising storage if data is removed. ● Compatible and non-compatible changes for existing clients ● Dependencies between schema and clients ● Replication ● Backup and Restore Schema management
  • 8. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.8 Schema object versions + NdbApi ● Visible via ndb_show_tables (and ndbinfo in 7.4+) ● Online change (e.g. add column) increments minor version ● Offline change (e.g. drop column) increments major version (or changes schema object id) ● NdbApi clients have a schema object cache, where each object is versioned. ● NdbApi operations carry the schema object versions they were defined against. ● If the data node's version differs only in the minor version, the operation can proceed. If it differs in major version, it is rejected. ● On schema object version error, clients will invalidate their local objects and re-fetch. Schema management
  • 9. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.9 Schema object versions + NdbApi ● This mechanism allows online schema upgrades where clients can lazily update their schema object caches. MySQLD approach MySQLD is involved in all schema changes via schema distribution. Schema changes are logically made to occur on epoch boundaries. MySQLD controls (its) schema object invalidation. MySQLD controls the schema used for Binlogging at any point in time, Schema management
  • 10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.10 Replication ● Replication supports a set of attribute (column) type promotions and demotions, as well as different numbers of columns at Master + Slave. ● This allows different schemas at Master and Slave Backup + Restore ndb_restore supports a set of column type promotions and demotions designed to mirror those supported by replication. This allows B+R on a slave with different cluster to be a schema change mechanism and ensures that the worst-case recovery mechanism (B+R) works even when schemas are misaligned between replicas. Schema management