Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

Panel

Summary

Extension to support the tool pt-online-schema-change from Percona Toolkit. This extension replaces a couple of the default changes to use pt-online-schema-change instead of SQL. This allows to perform a non-locking database upgrade.

Current Version

1.2.

0

1

Author

Andreas Dangel (adangel [at] users.sf.net)

Issue Tracking

https://github.com/adangel/liquibase-percona/issues

Source Repository

https://github.com/adangel/liquibase-percona.git

Maven Coordinates

com.github.adangel.liquibase.ext:liquibase-percona

Supported Database

MySQL

...


News

October 19, 2014

1.0.0

  • compatible with liquibase 3.2.x
November 6, 20141.1.0
  • compatible with liquibase 3.3.0
July 26, 20151.1.1
  • Fixed #1: Tables with foreign keys
April 2, 20161.2.0
  • Fixed #2: Adding indexes via pt-online-schema-change
  • Fixed #3: Altering column data types via pt-online-schema-change
  • Added configuration property "liquibase.percona.skipChanges"
  • Upgraded liquibase to 3.4.2
September 13, 20161.2

...

.1
  • PR #4: Allow passing additional command line options to pt-online-schema-change
  • PR #5: Support afterColum attribute


Attachments

Readme

Supported Databases

...

  • Liquibase 3.2.0 (liquibase-percona 1.0.0)
  • Liquibase 3.3.0 (liquibase-percona 1.1.1)
  • Liquibase 3.3.5 and 3.4.2 (liquibase-percona 1.2.01)

Supported Changes and examples

...

  • liquibase.percona.failIfNoPT: true/false. Default: false. If set to true, the database update will fail, if the command pt-online-schema-change is not found. This can be used, to enforce, that percona toolkit is used.

  • liquibase.percona.noAlterSqlDryMode: true/false. Default: false. When running updateSQL or rollbackSQL in order to generate a migration SQL file, the command line, that would be executed, will be added as a comment. In addition, the SQL statements (as produced by liquibase-core) will also be generated and output into the migration file. This allows to simply execute the generated migration SQL to perform an update. However, the Percona toolkit won't be used. If this property is set to true, then no such SQL statements will be output into the migration file.

  • liquibase.percona.skipChanges: comma separated list of changes. Default: . This option can be used in order to selectively disable one or more changes. If a change is disabled, then the change will be executed by the default liquibase core implementation and percona toolkit won't be used. By default, this property is empty, so that all supported changes are executed using the percona toolkit. Example: Set this to addColumn,dropColumn in order to not use percona for adding/dropping a column.

  • liquibase.percona.options: String of options. Default: <empty>.
    This option allows the user to pass additional command line options to pt-online-schema-change. This e.g. can be used in complication replication setup to change the way slaves are detected and how their state is used. You can also specify a percona configuration file via --config file.conf, see Configuration Files. Multiple options are separated by space. If argument itself contains a space, it must be quoted with double-quotes, e.g. --config "filename with spaces.conf.

You can set these properties by using the standard java -D option:

...

When executing liquibase through maven, you can use the Properties Maven Plugin to set the system property. An example can be found in the "createIndexSkipped" integration test. 


Using / Installing the extension

...

The jar files can be downloaded manually from maven:

httphttps://repo1repo.maven.apache.org/maven2/com/github/adangel/liquibase/ext/liquibase-percona/

Command line liquibase

After extracting the zip file of liquibase, place liquibase-percona-1.2.01.jar file in the sub directory lib. The shell script liquibase / liquibase.bat will automatically pick this up and the extension is available.

...

<dependency>
    <groupId>com.github.adangel.liquibase.ext</groupId>
    <artifactId>liquibase-percona</artifactId>
    <version>1.2.0<1</version>
</dependency>

Using snapshots

...

And just use the latest SNAPSHOT version for liquibase-percona dependency, e.g. 1.2.12-SNAPSHOT:

<dependency>
    <groupId>com.github.adangel.liquibase.ext</groupId>
    <artifactId>liquibase-percona</artifactId>
    <version>1.2.12-SNAPSHOT</version>
</dependency>

...


Notes

The non-locking update is achieved using triggers. First a new temporary table is created, including the added or dropped columns. Then the data is copied in chunks. While the copy is in progress, any newly created or deleted or updated rows are copied, too. This is done by adding triggers to the original table. After the copy is finished, the original table is dropped and the temporary table is renamed.

...

The command pt-online-schema-change is searched only on the PATH. Depending on the property liquibase.percona.failIfNoPT the update will fail or will just run without using pt-online-schema-change and potentially lock the table for the duration of the update.

 


Building this extension

Simply run mvn clean verify. You'll find the jar-file in the target/ subdirectory.

...

See the properties config_... in pom.xml for connection details for the mysql docker instance.

 


Common Problems

NoSuchMethodError: PerconaDropColumnChange.getColumns()Ljava/util/List

...

...