forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vtbackup: disable redo log before starting replication (vitessio#11330)
* vtbackup: disable redo log before starting replication According to MySQL docs: > As of MySQL 8.0.21, you can disable redo logging using the ALTER > INSTANCE DISABLE INNODB REDO_LOG statement. This functionality is > intended for loading data into a new MySQL instance. Disabling redo > logging speeds up data loading by avoiding redo log writes and > doublewrite buffering. See: https://dev.mysql.com/doc/refman/8.0/en/innodb-redo-log.html#innodb-disable-redo-logging We can take advantage of this in vtbackup. This change disables the redo log on MySQL >= 8.0.21 before starting replication, and re-enables the redo log after stopping replication. Signed-off-by: Max Englander <max@planetscale.com> * non-fatal error, robus status check, copyright current year Signed-off-by: Max Englander <max@planetscale.com> * try checking redo log status in vtbackup e2e test Signed-off-by: Max Englander <max@planetscale.com> * retain vtbackup temporary files so we can verify them in e2e test Signed-off-by: Max Englander <max@planetscale.com> * make e2e test work with upgrade/downgrade tests Signed-off-by: Max Englander <max@planetscale.com> * check for mysql 8.0.21 in e2e test redo log assertions Signed-off-by: Max Englander <max@planetscale.com> * fmt.Println debug Signed-off-by: Max Englander <max@planetscale.com> * perconnnaaaaaa Signed-off-by: Max Englander <max@planetscale.com> * fix e2e flags Signed-off-by: Max Englander <max@planetscale.com> * simplify e2e test, revert flags and cnf cruft Signed-off-by: Max Englander <max@planetscale.com> * capitalize log msgs Signed-off-by: Max Englander <max@planetscale.com> * dont verify redo log for --initial_backup Signed-off-by: Max Englander <max@planetscale.com> * address pr comments: fix typo and remove package alias Signed-off-by: Max Englander <max@planetscale.com> * address pr comments: report redo log enabled when we can't disable Signed-off-by: Max Englander <max@planetscale.com> * rely on mysql server variable to determine if can disable/enable redo log Signed-off-by: Max Englander <max@planetscale.com> * split up binary vs. process redo log capability Signed-off-by: Max Englander <max@planetscale.com> * simplify further Signed-off-by: Max Englander <max@planetscale.com> * Address my own pedantic nits Signed-off-by: Matt Lord <mattalord@gmail.com> * Sorry, can't help myself Signed-off-by: Matt Lord <mattalord@gmail.com> Signed-off-by: Max Englander <max@planetscale.com> Signed-off-by: Matt Lord <mattalord@gmail.com> Co-authored-by: Matt Lord <mattalord@gmail.com>
- Loading branch information
Showing
8 changed files
with
160 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2022 The Vitess Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package mysqlctl | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
) | ||
|
||
func (mysqld *Mysqld) BinaryHasDisableRedoLog() bool { | ||
return mysqld.capabilities.hasDisableRedoLog() | ||
} | ||
|
||
func (mysqld *Mysqld) DisableRedoLog(ctx context.Context) error { | ||
return mysqld.ExecuteSuperQuery(ctx, "ALTER INSTANCE DISABLE INNODB REDO_LOG") | ||
} | ||
|
||
func (mysqld *Mysqld) EnableRedoLog(ctx context.Context) error { | ||
return mysqld.ExecuteSuperQuery(ctx, "ALTER INSTANCE ENABLE INNODB REDO_LOG") | ||
} | ||
|
||
func (mysqld *Mysqld) ProcessCanDisableRedoLog(ctx context.Context) (bool, error) { | ||
qr, err := mysqld.FetchSuperQuery(ctx, "SELECT variable_value FROM performance_schema.global_status WHERE variable_name = 'innodb_redo_log_enabled'") | ||
if err != nil { | ||
// It's possible that the MySQL process can disable redo logging, but | ||
// we were unable to connect in order to verify. Let's assume not and | ||
// let the caller decide if they want to retry. | ||
return false, err | ||
} | ||
if len(qr.Rows) == 0 { | ||
return false, fmt.Errorf("mysqld >= 8.0.21 required to disable the redo log") | ||
} | ||
return true, nil | ||
} |