-
Notifications
You must be signed in to change notification settings - Fork 709
br: add compact log backup #20342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
br: add compact log backup #20342
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5fce533
Add temp.md
lilin90 fd2c809
Delete temp.md
lilin90 a753eae
toc, br: add compact log backup
lilin90 2491bf1
Update wording
lilin90 3842770
Remove example output
lilin90 e525f8a
Apply suggestions from code review
lilin90 03efbd0
Apply suggestions from code review
lilin90 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,85 @@ | ||
| --- | ||
| title: Compact Log Backup | ||
| summary: Learn how to improve Point-in-time Recovery (PITR) efficiency by compacting log backups into the SST format. | ||
| --- | ||
|
|
||
| # Compact Log Backup | ||
|
|
||
| This document describes how to improve the efficiency of point-in-time recovery (PITR) by compacting log backups into the [SST](/glossary.md#static-sorted-table--sorted-string-table-sst) format. | ||
|
|
||
| ## Overview | ||
|
|
||
| Traditional log backups store write operations in a highly unstructured manner, which can lead to the following issues: | ||
|
|
||
| - **Reduced recovery performance**: disordered data needs to be written to the cluster one by one through the Raft protocol. | ||
lilin90 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - **Write amplification**: repeated write operations increase storage pressure. | ||
lilin90 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - **Dependency on full backups**: frequent full backups are required to control the amount of recovery data, which can impact application operations. | ||
|
|
||
| Starting from v9.0.0, the compact log backup feature provides offline reorganization capabilities, converting unstructured log backup data into structured SST files. This results in the following improvements: | ||
lilin90 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| - **Enhanced recovery performance**: structured data supports efficient batch writes. | ||
| - **Optimized storage space**: reduces redundant data storage. | ||
| - **Extended full backup intervals**: minimizes the impact on application operations. | ||
lilin90 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Limitations | ||
|
|
||
| - Compact log backup is not a replacement for full backups. It must be used in conjunction with regular full backups. To ensure PITR capability, the compacting process retains MVCC data. Prolonged intervals without full backups can lead to excessive storage usage and recovery issues. | ||
lilin90 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - Currently, compacting backups with local encryption enabled is not supported. | ||
|
|
||
| ## Use compact log backup | ||
|
|
||
| Currently, only manual compaction of log backups is supported, and the process is complex. **It is recommended to use the coming TiDB Operator solution for compacting log backups in production environments.** | ||
|
|
||
| ### Manual compaction | ||
|
|
||
| This section describes the steps for manually compacting log backups. | ||
|
|
||
| #### Prerequisites | ||
|
|
||
| Manual compaction of log backups requires two tools: `tikv-ctl` and `br`. | ||
|
|
||
| #### Step 1: Encode storage to Base64 | ||
|
|
||
| Execute the following encoding command: | ||
|
|
||
| ```shell | ||
| br operator base64ify --storage "s3://your/log/backup/storage/here" --load-creds | ||
| ``` | ||
|
|
||
| > **Note:** | ||
| > | ||
| > - If the `--load-creds` option is included when you execute the preceding command, the encoded Base64 string contains credential information loaded from the current BR environment. Note to ensure proper security and access control. | ||
| > - The `--storage` value matches the storage output from the `log status` command of the log backup task. | ||
|
|
||
| #### Step 2: Execute log compaction | ||
|
|
||
| With the Base64-encoded storage, you can initiate the compaction using `tikv-ctl`. Note that the default log level of `tikv-ctl` is `warning`. Use `--log-level info` to obtain more detailed information: | ||
|
|
||
| ```shell | ||
| tikv-ctl --log-level info compact-log-backup \ | ||
| --from "<start-tso>" --until "<end-tso>" \ | ||
| -s 'bAsE64==' -N 8 | ||
| ``` | ||
|
|
||
| Parameter descriptions: | ||
|
|
||
| - `-s`: the Base64-encoded storage string obtained earlier. | ||
| - `-N`: the maximum number of concurrent log compaction tasks. | ||
| - `--from`: the start timestamp for compaction. | ||
| - `--until`: the end timestamp for compaction. | ||
|
|
||
| The `--from` and `--until` parameters define the time range for the compaction operation. The compaction operation handles all log files containing write operations within the specified time range, so the generated SST files might include data outside this range. | ||
|
|
||
| To obtain the timestamp for a specific point in time, execute the following command: | ||
|
|
||
| ```shell | ||
| echo $(( $(date --date '2004-05-06 15:02:01Z' +%s%3N) << 18 )) | ||
| ``` | ||
|
|
||
| > **Note:** | ||
| > | ||
| > If you are a macOS user, you need to install `coreutils` via Homebrew and use `gdate` instead of `date`. | ||
| > | ||
| > ```shell | ||
| > echo $(( $(gdate --date '2004-05-06 15:02:01Z' +%s%3N) << 18 )) | ||
| > ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.