mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
WL#1596 "make mysqldump --master-data --single-transaction able to do online dump of InnoDB AND report reliable
binlog coordinates corresponding to the dump". The good news is that now mysqldump can be used to get an online backup of InnoDB *which works for point-in-time recovery and replication slave creation*. Formerly, mysqldump --master-data --single-transaction used to call in fact mysqldump --master-data, so the dump was not an online dump (took big lock all time of dump). The only lock which is now taken in this patch is at the beginning of the dump: mysqldump does: FLUSH TABLES WITH READ LOCK; START TRANSACTION WITH CONSISTENT SNAPSHOT; SHOW MASTER STATUS; UNLOCK TABLES; so the lock time is in fact the time FLUSH TABLES WITH READ LOCK takes to return (can be 0 or very long, if a table is undergoing a huge update). I have done some more minor changes listed in the paragraph of mysqldump.c. WL#2237 "WITH CONSISTENT SNAPSHOT clause for START TRANSACTION": it's a START TRANSACTION which additionally starts a consistent read on all capable storage engine (i.e. InnoDB). So, can serve as a replacement for BEGIN; SELECT * FROM some_innodb_table LIMIT 1; which starts a consistent read too.
This commit is contained in:
@@ -3076,6 +3076,12 @@ purposes internal to the MySQL server", MYF(0));
|
||||
}
|
||||
|
||||
case SQLCOM_UNLOCK_TABLES:
|
||||
/*
|
||||
It is critical for mysqldump --single-transaction --master-data that
|
||||
UNLOCK TABLES does not implicitely commit a connection which has only
|
||||
done FLUSH TABLES WITH READ LOCK + BEGIN. If this assumption becomes
|
||||
false, mysqldump will not work.
|
||||
*/
|
||||
unlock_locked_tables(thd);
|
||||
if (thd->options & OPTION_TABLE_LOCK)
|
||||
{
|
||||
@@ -3462,7 +3468,9 @@ purposes internal to the MySQL server", MYF(0));
|
||||
thd->options= ((thd->options & (ulong) ~(OPTION_STATUS_NO_TRANS_UPDATE)) |
|
||||
OPTION_BEGIN);
|
||||
thd->server_status|= SERVER_STATUS_IN_TRANS;
|
||||
send_ok(thd);
|
||||
if (!(lex->start_transaction_opt & MYSQL_START_TRANS_OPT_WITH_CONS_SNAPSHOT) ||
|
||||
!(res= ha_start_consistent_snapshot(thd)))
|
||||
send_ok(thd);
|
||||
}
|
||||
break;
|
||||
case SQLCOM_COMMIT:
|
||||
|
||||
Reference in New Issue
Block a user