From 59e90bfcb3861b51d6ea5b269f5dd6ba08eb68b7 Mon Sep 17 00:00:00 2001 From: Paul R Rogers Date: Thu, 16 Jul 2020 14:16:21 -0400 Subject: [PATCH] Fix/unnecessary locking (#21) * fix(MigrateDumpCommand): Only include routines when dumping structure/schema. * fix(MigrateDumpCommand): Use single transaction to avoid locking. * chore(MigrateDumpCommand): Single transaction even for migrations table. --- src/Commands/MigrateDumpCommand.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Commands/MigrateDumpCommand.php b/src/Commands/MigrateDumpCommand.php index 416e2df..c5d8adf 100644 --- a/src/Commands/MigrateDumpCommand.php +++ b/src/Commands/MigrateDumpCommand.php @@ -141,7 +141,8 @@ private static function mysqlSchemaDump(array $db_config, string $schema_sql_pat passthru( static::mysqlCommandPrefix($db_config) . ' --result-file=' . escapeshellarg($schema_sql_path) - . ' --no-data', + . ' --no-data' + . ' --routines', $exit_code ); @@ -167,6 +168,7 @@ private static function mysqlSchemaDump(array $db_config, string $schema_sql_pat . ' --no-create-info' . ' --skip-extended-insert' . ' --skip-routines' + . ' --single-transaction' . ' --compact', $output, $exit_code @@ -201,7 +203,8 @@ private static function mysqlDataDump(array $db_config, string $data_sql_path) : static::mysqlCommandPrefix($db_config) . ' --result-file=' . escapeshellarg($data_sql_path) . ' --no-create-info --skip-routines --skip-triggers' - . ' --ignore-table=' . escapeshellarg($db_config['database'] . '.migrations'), + . ' --ignore-table=' . escapeshellarg($db_config['database'] . '.migrations') + . ' --single-transaction', // Avoid disruptive locks. $exit_code ); @@ -237,7 +240,7 @@ private static function mysqlCommandPrefix(array $db_config) : string // Not including connection name in file since typically only one DB. // Excluding any hash or date suffix since only current is relevant. - return 'mysqldump --routines --skip-add-drop-table' + return 'mysqldump --skip-add-drop-table' . ' --skip-add-locks --skip-comments --skip-set-charset --tz-utc --set-gtid-purged=OFF' . ' --host=' . escapeshellarg($db_config['host']) . ' --port=' . escapeshellarg($db_config['port'])