From 47e31b894e12ca7cc8c476e5b3a194d7d0e15884 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Mon, 7 Oct 2019 09:49:47 -0400 Subject: [PATCH] Add --skip-locks flag to mysql-migrate-db.sh The --skip-locks flag can be used along with --migrate in deployments where table locking operations can't be performed. For example, Percona XtraDB Cluster only has experimental support for explicit table locking operations and attempts to use locking will result in errors when PXC Strict Mode is set to ENFORCING. Change-Id: I3df5686d13c1ce0cc38402a1317acb661ad74cec Story: #2006670 --- doc/source/admin/upgrade-to-stein.rst | 6 ++++++ placement_db_tools/mysql-migrate-db.sh | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/source/admin/upgrade-to-stein.rst b/doc/source/admin/upgrade-to-stein.rst index 0915adae7..b0d6ff49a 100644 --- a/doc/source/admin/upgrade-to-stein.rst +++ b/doc/source/admin/upgrade-to-stein.rst @@ -162,6 +162,12 @@ Migrate the Data $ mysql-migrate-db.sh --migrate /tmp/migrate-db.rc + The ``--skip-locks`` flag can be used along with ``--migrate`` in + deployments where table locking operations can't be performed. For example, + Percona XtraDB Cluster only has experimental support for explicit table + locking operations and attempts to use locking will result in errors when + PXC Strict Mode is set to ENFORCING. + If your controller host (the one where you have been editing ``/etc/placement/placement.conf``) and database host are not the same, and you have run the migration script on the database host, the final step in diff --git a/placement_db_tools/mysql-migrate-db.sh b/placement_db_tools/mysql-migrate-db.sh index 7d4343ba1..2a9f32dc6 100755 --- a/placement_db_tools/mysql-migrate-db.sh +++ b/placement_db_tools/mysql-migrate-db.sh @@ -147,11 +147,12 @@ function migrate_data() { # Usage: migrate_data NOVA_API PLACEMENT -> 0 local source="$1" local dest="$2" + local dump_flags="$3" local tmpdir=$(mktemp -d migrate-db.XXXXXXXX) local tmpfile="${tmpdir}/from-nova.sql" echo "Dumping from $source to $tmpfile" - mysql_command $source mysqldump $MIGRATE_TABLES > $tmpfile || { + mysql_command $source mysqldump $dump_flags $MIGRATE_TABLES > $tmpfile || { echo 'Failed to dump source database:' show_error return 1 @@ -223,6 +224,7 @@ function show_help() { echo " --help: this text" echo " --migrate: actually do data migration" echo " --mkconfig: write/update config to \$rcfile" + echo " --skip-locks: don't use table locks for data migration" echo echo "Pass '-' as \$rcfile if all config values are set in" echo "the environment." @@ -292,7 +294,11 @@ fi echo Nova database contains data, placement database does not. Okay to proceed with migration if getflag migrate $*; then - migrate_data NOVA_API PLACEMENT + if getflag skip-locks $*; then + migrate_data NOVA_API PLACEMENT "--skip-lock-tables --skip-add-locks" + else + migrate_data NOVA_API PLACEMENT + fi placement-manage db stamp $INITIAL_PLACEMENT_DB_VERSION else echo "To actually migrate, run me with --migrate"