-
Notifications
You must be signed in to change notification settings - Fork 709
v8.5.5 br: add compact log backup (#20342) #22209
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
Open
ti-chi-bot
wants to merge
9
commits into
pingcap:release-8.5
Choose a base branch
from
ti-chi-bot:cherry-pick-20342-to-release-8.5
base: release-8.5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1fced6d
Add temp.md
lilin90 ac1d245
Delete temp.md
lilin90 f429bb6
toc, br: add compact log backup
lilin90 0cec46d
Update wording
lilin90 a259ba0
Remove example output
lilin90 5c05df8
Apply suggestions from code review
lilin90 42189e9
Apply suggestions from code review
lilin90 56d8c95
Apply suggestions from code review
lilin90 9446d14
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](/glossary.md#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**: unordered data has to be written to the cluster one by one through the Raft protocol. | ||
| - **Write amplification**: all writes must be compacted from L0 to the bottommost level by level. | ||
lilin90 marked this conversation as resolved.
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 v8.5.5, the compact log backup feature provides offline compaction capabilities, converting unstructured log backup data into structured SST files. This results in the following improvements: | ||
|
|
||
| - SST files can be quickly imported into the cluster, **improving recovery performance**. | ||
| - Redundant data is removed during compaction, **reducing storage space consumption**. | ||
| - You can set longer full backup intervals while ensuring the Recovery Time Objective (RTO), **reducing the impact on applications**. | ||
|
|
||
| ## Limitations | ||
|
|
||
| - Compact log backup is not a replacement for full backups. It must be used in conjunction with periodic full backups. To ensure PITR capability, the compacting process retains all MVCC versions. Failing to perform full backups for a long time can lead to excessive storage usage and might cause issues when restoring data later. | ||
| - 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 upcoming 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. | ||
lilin90 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| > - 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.