Skip to content

Avoid raceconditions in global activate, run and global run #3285

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 3 commits into from
Jan 20, 2022

Conversation

sigurdm
Copy link
Contributor

@sigurdm sigurdm commented Jan 13, 2022

Attempts to fix: #3165

This is done by:

global activate:

  • Activating a global package into a temp-dir and renaming the dir into the right place.
    Two concurrent activations of the same package foo will not be able to both contribute to the resulting files, an observer will always see the result of one or the other or none in $PUB_CACHE/global_packages/foo.

  • Creating binstubs in a temp-dir, making them executable and then moving them into the right place.
    It won't be possible to observe half a binstub, or for chmod to have the binstub removed before it can operate on it.

run/global run:

  • Copying the incremental compilation data before compilation, and renaming the result to the right location.
    We already did a copy to preserve the incremental data, the change is to do the copy before compilation not after.

All of this builds on renaming being an atomic operation, another process will either see the old file or the new, never anything in-between.

There is still a possibility of confusing results if you concurrently dart pub global activate two different packages with overlapping binstub-names, then you can end up with any possible mixture of these binstubs - don't do that.

The pr contains quite some refactoring to allow global packages to exist in a temporary directory.

Also I took out support for pre dart-1.6 style lockfiles.
This fixes: #1111

@sigurdm
Copy link
Contributor Author

sigurdm commented Jan 13, 2022

@jakemac53 you might be interested in the changes to the precompilation (in dart.dart).

@sigurdm sigurdm requested a review from jonasfj January 13, 2022 13:18
Copy link
Contributor

@jakemac53 jakemac53 left a comment

Choose a reason for hiding this comment

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

These changes LGTM

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.

Running pub global run concurrently Remove special handling of the old global lockfiles in pub
3 participants