Skip to content

import_sstpb: add RestoreRegion RPC for snapshot restore - #1533

Open
RidRisR wants to merge 3 commits into
pingcap:masterfrom
RidRisR:import-sstpb-restore-region
Open

RidRisR wants to merge 3 commits into
pingcap:masterfrom
RidRisR:import-sstpb-restore-region

Conversation

@RidRisR

@RidRisR RidRisR commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What changed and how does it work?

Add ImportSST.RestoreRegion so BR can ask a target Region leader to restore snapshot SSTs through the cloud storage engine. The response reuses IngestResponse; success means the generated files have been applied. Failed or interrupted requests may already have taken effect, so the API does not promise idempotent retries.

RestoreRegionRequest carries the Region context, shared source storage and optional cipher configuration. Each RestoreRegionSource identifies a source write/default SST, its size, logical key-prefix/timestamp rewrite rule and optional IV. TiKV derives the crop range from the target Region. Timestamp filtering is unsupported.

This is an additive protocol change. Existing RPCs and the backup metadata format are unchanged. Include regenerated Go bindings and the compatibility lock; Rust bindings are generated at build time.

Validation

  • make proto-fmt-check
  • protolock status against both the updated lock and the upstream master lock
  • Regenerated import_sstpb using the repository's generation options; git diff --exit-code remained clean
  • go test ./pkg/import_sstpb (package compilation; no test files)
  • go build ./pkg/...
  • cargo check --locked -j 8
  • cargo check --locked --no-default-features --features prost-codec -j 8
  • git diff --check origin/master...HEAD

The protocol source is byte-for-byte identical to the version used by both BR and TiKV in a prior end-to-end full-snapshot restore test (write/default CFs, secondary index, checksum and three-replica Apply). That test used local dependency overrides on older dependency baselines; integration after updating consumers to this PR revision remains separate work.

C++ generation/build and a new end-to-end consumer run on this rebased revision were not run locally.

Summary by CodeRabbit

  • New Features
    • Added support for restoring a complete snapshot into an existing region.
    • Added configuration for target-region context, shared storage, source SST files, column families, rewrite rules, file lengths, and encryption settings.
    • Added optional restore task identification to coordinate multiple region restore requests while preserving legacy one-shot behavior.
    • Added capability reporting for durable restore-task deduplication and bounded-retry error handling.

Signed-off-by: ris <79858083+RidRisR@users.noreply.github.com>
@ti-chi-bot

ti-chi-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign ichn-hu, zhangjinpeng87 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 8, 2026
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 8280702d-db7a-43f6-b2e4-88d60c42611f

📥 Commits

Reviewing files that changed from the base of the PR and between 523f83e and 698a895.

⛔ Files ignored due to path filters (2)
  • pkg/import_sstpb/import_sstpb.pb.go is excluded by !**/*.pb.go
  • scripts/proto.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • proto/import_sstpb.proto

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The import SST protocol adds RestoreRegion for restoring snapshot SST files into an existing region. It defines request and source metadata, optional batch identity, and Store support reporting for durable retry handling.

Changes

Region Restore

Layer / File(s) Summary
Restore RPC and request contract
proto/import_sstpb.proto
Adds the RestoreRegion RPC, RestoreRegionRequest, and RestoreRegionSource. The contract defines region context, storage and encryption settings, source SST metadata, rewrite rules, optional 32-byte restore_task_id, and supports_restore_region_retry capability reporting.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 698a8

The new RPC contract and generated binding shape are compatible in the supplied evidence, with no concrete merge-blocking issue identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding the RestoreRegion RPC for snapshot restoration in import_sstpb.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 Buf (1.72.0)
proto/import_sstpb.proto

fatal: unable to access 'https://github.com/pingcap/kvproto.git/': Failed to connect to github.com:443 over proxy 127.0.0.1 after 0 ms: Could not connect to server
fatal: could not fetch b230d31bcca323aaade91c6a6805f97fb1124b19 from promisor remote


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit carries SSTs through the gate
RestoreRegion makes the path straight
Source files bring their names and size
Rewrite rules guide each surprise
A task ID helps retries stay clear
The Store reports support for work held near

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: ris <79858083+RidRisR@users.noreply.github.com>
Signed-off-by: ris <79858083+RidRisR@users.noreply.github.com>
@ti-chi-bot

ti-chi-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-linked-issue label, please provide the linked issue number on one line in the PR body, for example: Issue Number: close #123 or Issue Number: ref #456.

📖 For more info, you can check the "Contribute Code" section in the development guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/needs-linked-issue size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant