Skip to content

Refactor Collection::restore_shard_snapshot#6988

Merged
ffuugoo merged 3 commits intodevfrom
partial-snapshot-cancel-safety
Aug 6, 2025
Merged

Refactor Collection::restore_shard_snapshot#6988
ffuugoo merged 3 commits intodevfrom
partial-snapshot-cancel-safety

Conversation

@ffuugoo
Copy link
Contributor

@ffuugoo ffuugoo commented Aug 6, 2025

This PR makes two improvements to Collection::restore_shard_snapshot:

First, it makes it cancel-safe, so that it's a bit safer to use. I don't think we have any issues with this method as-is, but it's just nice to have.

Second, restructures restore_shard_snapshot as a "two-step" future. It now returns additional future. E.g.:

// `restore_shard_snapshot` is `async fn`, that returns a future, that perfoms *validation* of snapshot archive
let validate = collection.restore_shard_snapshot(...);

// when you `await` it, it returns *another* future, that performs snapshot restore *in background*
// (we can await first future to validate snapshot with `wait=false`, and return an error *before* returning `accepted`)
let restore = validate.await?;

// and you can await this future *if you want to* to get result of recovery
// (we can await this to return response with `wait=true`)
let result = restore.await?;

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --all --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@coderabbitai

This comment was marked as off-topic.

coderabbitai[bot]

This comment was marked as off-topic.

@ffuugoo ffuugoo requested review from generall and timvisee August 6, 2025 11:27
Copy link
Member

@generall generall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as soon as all .into is replaced

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants