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
This commit is contained in:
Corey Bryant 2019-10-07 09:49:47 -04:00
parent dbd0386711
commit 47e31b894e
2 changed files with 14 additions and 2 deletions

View File

@ -162,6 +162,12 @@ Migrate the Data
$ mysql-migrate-db.sh --migrate /tmp/migrate-db.rc $ 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 If your controller host (the one where you have been editing
``/etc/placement/placement.conf``) and database host are not the same, and ``/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 you have run the migration script on the database host, the final step in

View File

@ -147,11 +147,12 @@ function migrate_data() {
# Usage: migrate_data NOVA_API PLACEMENT -> 0 # Usage: migrate_data NOVA_API PLACEMENT -> 0
local source="$1" local source="$1"
local dest="$2" local dest="$2"
local dump_flags="$3"
local tmpdir=$(mktemp -d migrate-db.XXXXXXXX) local tmpdir=$(mktemp -d migrate-db.XXXXXXXX)
local tmpfile="${tmpdir}/from-nova.sql" local tmpfile="${tmpdir}/from-nova.sql"
echo "Dumping from $source to $tmpfile" 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:' echo 'Failed to dump source database:'
show_error show_error
return 1 return 1
@ -223,6 +224,7 @@ function show_help() {
echo " --help: this text" echo " --help: this text"
echo " --migrate: actually do data migration" echo " --migrate: actually do data migration"
echo " --mkconfig: write/update config to \$rcfile" echo " --mkconfig: write/update config to \$rcfile"
echo " --skip-locks: don't use table locks for data migration"
echo echo
echo "Pass '-' as \$rcfile if all config values are set in" echo "Pass '-' as \$rcfile if all config values are set in"
echo "the environment." echo "the environment."
@ -292,7 +294,11 @@ fi
echo Nova database contains data, placement database does not. Okay to proceed with migration echo Nova database contains data, placement database does not. Okay to proceed with migration
if getflag migrate $*; then 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 placement-manage db stamp $INITIAL_PLACEMENT_DB_VERSION
else else
echo "To actually migrate, run me with --migrate" echo "To actually migrate, run me with --migrate"