Skip to content

Workspace store deadlock protection #9132

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 2 commits into from
Dec 13, 2024

Conversation

touilleMan
Copy link
Contributor

  • Hide WorkspaceStore's cache & storage (i.e. local db) internals
  • Access must be done through callback API to limit the scope the lock is taken
  • A runtime deadlock detector is present in debug build \o/

@touilleMan touilleMan marked this pull request as ready for review December 6, 2024 16:45
@touilleMan touilleMan requested a review from a team as a code owner December 6, 2024 16:45
@touilleMan touilleMan force-pushed the workspace-store-deadlock-protection branch 6 times, most recently from 0debfb6 to 563eb26 Compare December 12, 2024 13:25

let outcome = cache_guard.lock_update_manifests.take(entry_id);
match outcome {
enum LockForUpdateOutcome {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't that the same struct as in file_updater.rs ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but I don't think it is worth it to factorize it since this is purely implementation detail of for_update_* code (that's why it is defined within the function body).

Basically factorize just a type would create an artificial relationship between two unrelated pieces of code that use it, which typically cause issue when modifying one piece but not the other (on top of adding complexity when reading the code since the type definition end up in another file).

However you're right on the fact both for_update_* functions have very similar implementations, so we should be able to factorize the entire implementation. I will look into this in my next PR (see #9153) that will modify part of this code anyway.

@touilleMan touilleMan force-pushed the workspace-store-deadlock-protection branch from 563eb26 to 7f83bbe Compare December 13, 2024 09:23
@touilleMan touilleMan force-pushed the workspace-store-deadlock-protection branch from 7f83bbe to 3233fd5 Compare December 13, 2024 09:34
// parent (i.e. `for_write`) or the grand-parent (i.e.
// `CertificateOps::add_certificates_batch`) which are going to poll this
// future directly, so the references' lifetimes *are* long enough.
// TODO: Remove this once async closure are available
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: Will be available in 1.85

rust-lang/rust#132706

@touilleMan touilleMan added this pull request to the merge queue Dec 13, 2024
Merged via the queue into master with commit e50a6ad Dec 13, 2024
14 checks passed
@touilleMan touilleMan deleted the workspace-store-deadlock-protection branch December 13, 2024 12:10
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