-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PXB-3254 Document reduction in locks
modified: docs/lock-options.md new file: docs/reduction-in-locks.md modified: docs/xtrabackup-option-reference.md modified: mkdocs-base.yml
- Loading branch information
1 parent
f546dc9
commit bdd5fb9
Showing
4 changed files
with
90 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Reduced backup lock time | ||
|
||
!!! important | ||
|
||
The `--lock-ddl=REDUCED` option is a [tech preview](./glossary.md#tech-preview). Before using this option in production, we recommend that you test restoring production from physical backups in your environment, and also use the alternative backup method for redundancy. | ||
|
||
Percona Server for MySQL implemented `LOCK TABLES FOR BACKUP` to block Data Definition Language (DDL) statements on a server. Percona XtraBackup utilizes this lock during the backup process to ensure that any `DDL` event does not corrupt the backup. The lock does not affect the Data Manipulation Language (DML) statements. | ||
|
||
## How the backup lock works | ||
|
||
With the [`--lock-ddl=ON`](./xtrabackup-option-reference.md/#lock-ddl) option the backup lock is enabled by default from the start of the backup process. | ||
|
||
* Set a backup lock: Set a backup lock on the server to prevent any `DDL` operations, ensuring no new tables are created, renamed, or dropped during the backup. | ||
|
||
* Copy the redo logs: Transfer all redo logs from the checkpoint up to the current Log Sequence Number (LSN) and start tracking new entries. | ||
|
||
* Identify and copy all InnoDB tablespace, `.ibd`, files. This step takes most of the time and is performed under the lock. | ||
|
||
* Copy non-InnoDB files. | ||
|
||
* Gather sync point: Collect synchronization points from all engines (InnoDB LSN, binlog, Global Transaction Identifier (GTID), etc.) by querying the log status. | ||
|
||
* Stop the redo follow thread: Cease the redo fllow thread once it has copied up to the sync point. | ||
|
||
* Release the backup lock on the server. | ||
|
||
If the backup lock is disabled with the [`--lock-ddl=OFF`](./xtrabackup-option-reference.md/#lock-ddl) option, a backup continues while concurrent DDL events are executed. These backups may be invalid and may fail at either the `backup` or the `--prepare` step. | ||
|
||
## The `--lock-ddl=REDUCED` option overview | ||
|
||
[Percona XtraBackup 8.4.0-2](./release-notes/8.4.0-2.md) adds the [`--lock-ddl=REDUCED`](./xtrabackup-option-reference.md/#lock-ddl) option to reduce the time the server remains under the backup lock. Now, you can execute more `DDL` operations concurrently while the backup is in progress. The backup lock is now taken after copying the `.ibd` files and before copying the `non-InnoDB` files. | ||
|
||
Copying the InnoDB files with the `--lock-ddl=REDUCED` option is split into two phases. | ||
|
||
### Phase 1: `Operations performed without the lock` | ||
|
||
1. Copying all redo logs from checkpoint up to the current LSN and start following new entries. | ||
2. Starting the redo log thread. | ||
3. Tracking file operations from the redo log. | ||
4. Copying of all .ibd without taking any lock. | ||
5. Acquiring Lock Tables For Backup (LTFB)/Lock Instance For Backup (LIFB). This step ensures no new DDL operations, such as creating or altering tables, will occur. | ||
6. Quering the log_status to discover the LSN. This step ensures that all subsequent operations are tracked and that the backup process captures a consistent state of the database. | ||
7. Copying all InnoDB files. | ||
8. Ensuring the redo log has catch up to LSN from step 5. | ||
|
||
### Phase 2: `Operations performed under the lock` | ||
|
||
9. Checking the file operations that were tracked and recopying the tablespaces. | ||
10. Creating additional `meta` files to perform the required actions (deletions or renames) on the already copied files. This approach ensures that the backup remains consistent and accurate without disrupting the streaming process. This step is required for taking streaming backups. | ||
11. Gathering a sync point from all engines (InnoDB LSN, binlog, GTID, etc.) by querying the `log_status`. | ||
12. Stoping the redo follow thread once it copies at least up to sync point at step 11. | ||
13. Releasing LTFB/LIFB. | ||
14. Processing the new files during `--prepare` phase before crash recovery starts. | ||
|
||
### Limitations | ||
|
||
1. The `ALTER INSTANCE ROTATE MASTER KEY` command should not be executed during [Phase 1](#phase-1-operations-performed-without-the-lock) if there are encrypted tables, as it will cause the backup to fail. | ||
|
||
2. The number of open file handles in your Operation System (OS) should be configured to match the number of files in the backup directory. | ||
|
||
3. When using the `--lock-ddl=REDUCED` option, backups can be larger in size. This happens because there are more operations allowed during backups. | ||
|
||
4. When the `DDL` operations that skip redo (for example, ADD INDEX) or change encryption types are executed while the backup is in progress, the `xtrabackup` can copy such tablespaces twice. | ||
|
||
### Benefits | ||
|
||
The `--lock-ddl=REDUCED` option key features are as follows: | ||
|
||
* Reduced locking: Rather than holding the backup lock throughout the entire backup process, it is only acquired for a very short period of time. | ||
|
||
* DDL statements: The server remains accessible for `DDL` operations during the backup process. | ||
|
||
* Consistency: Consistency is maintained by using the redo log to track file operations. During the backup process new metadata files are created to ensure consistency. In the `--prepare` phase, these metadata files are processed first to bring the database to a consistent state. | ||
|
||
|
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