diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-05-05 23:53:31 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-05-05 23:53:31 +0200 |
commit | 3792693f311a90cf195ec6d2f9b3762255a249c7 (patch) | |
tree | 6a7af45fff9c7ad7463310d1fe12e9d505547b2f /client | |
parent | f90dca1a0d78f4af9ab4355aaf325839034147ce (diff) | |
download | mariadb-git-3792693f311a90cf195ec6d2f9b3762255a249c7.tar.gz |
merge MySQL-5.6 bugfix "Bug#17862905: MYSQLDUMP CREATES USELESS METADATA LOCKS"
revno: 5716
committer: Praveenkumar Hulakund <praveenkumar.hulakund@oracle.com>
branch nick: mysql_5_6
timestamp: Sat 2013-12-28 22:08:40 +0530
message:
Bug#17862905: MYSQLDUMP CREATES USELESS METADATA LOCKS
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqldump.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/client/mysqldump.c b/client/mysqldump.c index a0222f370b3..b3a679261d7 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -4406,6 +4406,12 @@ static int dump_all_tables_in_db(char *database) else verbose_msg("-- dump_all_tables_in_db : logs flushed successfully!\n"); } + if (opt_single_transaction && mysql_get_server_version(mysql) >= 50500) + { + verbose_msg("-- Setting savepoint...\n"); + if (mysql_query_with_error_report(mysql, 0, "SAVEPOINT sp")) + DBUG_RETURN(1); + } while ((table= getTableName(0))) { char *end= strmov(afterdot, table); @@ -4423,6 +4429,23 @@ static int dump_all_tables_in_db(char *database) maybe_exit(EX_MYSQLERR); } } + + /** + ROLLBACK TO SAVEPOINT in --single-transaction mode to release metadata + lock on table which was already dumped. This allows to avoid blocking + concurrent DDL on this table without sacrificing correctness, as we + won't access table second time and dumps created by --single-transaction + mode have validity point at the start of transaction anyway. + Note that this doesn't make --single-transaction mode with concurrent + DDL safe in general case. It just improves situation for people for whom + it might be working. + */ + if (opt_single_transaction && mysql_get_server_version(mysql) >= 50500) + { + verbose_msg("-- Rolling back to savepoint sp...\n"); + if (mysql_query_with_error_report(mysql, 0, "ROLLBACK TO SAVEPOINT sp")) + maybe_exit(EX_MYSQLERR); + } } else { @@ -4445,6 +4468,14 @@ static int dump_all_tables_in_db(char *database) } } } + + if (opt_single_transaction && mysql_get_server_version(mysql) >= 50500) + { + verbose_msg("-- Releasing savepoint...\n"); + if (mysql_query_with_error_report(mysql, 0, "RELEASE SAVEPOINT sp")) + DBUG_RETURN(1); + } + if (opt_events && mysql_get_server_version(mysql) >= 50106) { DBUG_PRINT("info", ("Dumping events for database %s", database)); @@ -4687,6 +4718,13 @@ static int dump_selected_tables(char *db, char **table_names, int tables) if (opt_xml) print_xml_tag(md_result_file, "", "\n", "database", "name=", db, NullS); + if (opt_single_transaction && mysql_get_server_version(mysql) >= 50500) + { + verbose_msg("-- Setting savepoint...\n"); + if (mysql_query_with_error_report(mysql, 0, "SAVEPOINT sp")) + DBUG_RETURN(1); + } + /* Dump each selected table */ for (pos= dump_tables; pos < end; pos++) { @@ -4702,6 +4740,31 @@ static int dump_selected_tables(char *db, char **table_names, int tables) maybe_exit(EX_MYSQLERR); } } + + /** + ROLLBACK TO SAVEPOINT in --single-transaction mode to release metadata + lock on table which was already dumped. This allows to avoid blocking + concurrent DDL on this table without sacrificing correctness, as we + won't access table second time and dumps created by --single-transaction + mode have validity point at the start of transaction anyway. + Note that this doesn't make --single-transaction mode with concurrent + DDL safe in general case. It just improves situation for people for whom + it might be working. + */ + if (opt_single_transaction && mysql_get_server_version(mysql) >= 50500) + { + verbose_msg("-- Rolling back to savepoint sp...\n"); + if (mysql_query_with_error_report(mysql, 0, "ROLLBACK TO SAVEPOINT sp")) + maybe_exit(EX_MYSQLERR); + } + } + + if (opt_single_transaction && mysql_get_server_version(mysql) >= 50500) + { + verbose_msg("-- Releasing savepoint...\n"); + if (mysql_query_with_error_report(mysql, 0, "RELEASE SAVEPOINT sp")) + DBUG_RETURN(1); + } /* Dump each selected view */ |