Skip to content
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

Better error handling on switch creation #4121

Merged
merged 1 commit into from
Apr 9, 2020
Merged

Conversation

AltGr
Copy link
Member

@AltGr AltGr commented Apr 1, 2020

We used to release the lock on ~/.opam/config as soon as possible, but that is
not really compatible with the facts that:

  • we may want to set the switch as default upon creation (this was done early,
    but could lead to no switch getting selected on error)
  • we may want to clear the switch upon error (this was done without proper
    locking)

So this keeps the global lock during the switch installation, whith the
following benefits:

  • the selected switch is only changed once installation completes, not just
    after creation
  • changes to ~/.opam/config are handled safely

The alternative could be to release the lock, then try to acquire it again if
needed (on error, or for selecting the switch), but we chose the safer
approach. If the user really needs better lock granularity (e.g. creating many
switches in parallel), they could create all switches empty, then populate
them in parallel.

The last solution would be to remove the option to cleanup a partially
installed switch, and just tell the user with the command to properly remove
it.

We used to release the lock on ~/.opam/config as soon as possible, but that is
not really compatible with the facts that:
- we may want to set the switch as default upon creation (this was done early,
  but could lead to no switch getting selected on error)
- we may want to clear the switch upon error (this was done without proper locking)

So this keeps the global lock during the switch installation, whith the
following benefits:
- the selected switch is only changed once installation completes, not just
  after creation
- changes to ~/.opam/config are handled safely

The alternative could be to release the lock, then try to acquire it again if
needed (on error, or for selecting the switch), but we chose the safer approach.
If the user really needs better lock granularity (e.g. creating many switches in
parallel), they could create all switches empty, then populate them in parallel.

The last solution would be to remove the option to cleanup a partially installed
switch, and just tell the user with the command to properly remove it.
@rjbou rjbou added this to the 2.1.0~beta milestone Apr 1, 2020
@AltGr AltGr merged commit dee3349 into ocaml:master Apr 9, 2020
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.

2 participants