Skip to content

Delete collection dir on failed snapshot restore - #5984

Closed
agourlay wants to merge 1 commit into
devfrom
delete-malformed-collection-on-failed-restore
Closed

agourlay wants to merge 1 commit into
devfrom
delete-malformed-collection-on-failed-restore

Conversation

@agourlay

@agourlay agourlay commented Feb 13, 2025 •

Copy link
Copy Markdown
Member

Tackle #5983

In case of failed snapshot restore via the API, a malformed collection can be left behind preventing the service to properly restart.

This happens because in case of a restore of a non existing collection, we first create a collection and then restore shards into it.

We usually assume that all collection directory with configuration files are well formed but it is not the case anymore here.

Failing to restore a shard leaves behind a malformed collection.

The fix is to delete the whole collection directory IF it was absent before the recovery process.

@agourlay agourlay changed the title Delete collection dir on failed snapsdhot restore Delete collection dir on failed snapshot restore Feb 13, 2025
@agourlay
agourlay force-pushed the delete-malformed-collection-on-failed-restore branch from b937a72 to fb4d42b Compare February 13, 2025 15:15
@agourlay
agourlay marked this pull request as ready for review February 13, 2025 15:20

@timvisee timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Would it be possible to add a test for this?

@generall generall self-assigned this Feb 14, 2025
"Deleting collection directory for failed snapshot recovery: {:?}",
collection_path
);
tokio::fs::remove_dir_all(&collection_path).await?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we can do this in distributed environment. Consider cluster of 3 machines: one machine restores snapshot, 2 other create empty collection. If snapshot recovery fails, we only remove collection from one machine, 2 other machines will still think it exists.

@generall generall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There 2 problems:

  1. Proposed fix doesn't resolve problem if service is killed during snapshot recovery
  2. In will create inconsistency in distributed environment.

As an alternative I would propose some options:

  • make restore_local_replica_from cancel-safe.
  • tolerate non-existing shards on load and create empty ones instead
  • introduce a special type of file which would indicate that shard is not ready for load and should be ignored on load

@agourlay agourlay closed this Feb 17, 2025
@generall
generall deleted the delete-malformed-collection-on-failed-restore branch May 30, 2026 21:17
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