sendgrid-ops / pt-online-schema-change-plugins

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sendgrid pt-online-schema-change-plugins

(Forked from Yelp's work and edited for our use)

Introduction

These are some sample pt-online-schema-change plugins based off of the ones we use at Yelp when running pt-online-schema-change. Also included is a sample pt-online-schema-change.cnf, which you can deploy in /etc/percona-toolkit alongside the plugin.

To learn more about how Yelp uses pt-online-schema-change, you can check out Jenni Snyder's talk at Percona Live 2016, a link to the slides is at the bottom of the page.

The Plugins

init

An example of using the local database connection to obtain the database name, and using it in a command to announce the start of the pt-online-schema-change run in the dba and Announcements Hipchat channels.

before_exit

Like init, this plugin announces the finish of a pt-online-schema-change run.

before_create_new_table

Because pt-online-schema-change requires a user with the SUPER privilege, it's worth it to verify that it's running against a master withi read_only=0, and not, a replica with read_only=1.

before_swap_tables

We run pt-online-schema-change with --no-drop-old-table so that we can revert the change in case of an emergency. Having the master binary log coordinates is useful to examine changes from just before the point of swapping the new table in place.

Using

To use just a plugin file like this one, add:

--plugin /your/path/here/pt-online-schema-change-plugin.pl

to your pt-online-schema-change command.

Or, use an pt-online-schema-change.cnf like the one provided, which includes a reference to the plugin file. We use the default location of /etc/percona-toolkit for both.

About

License:MIT License


Languages

Language:Perl 100.0%