Skip to content

Close config files right after read - #1317

Draft
davidanthoff wants to merge 9 commits into
mainfrom
close-config-files-more
Draft

Close config files right after read#1317
davidanthoff wants to merge 9 commits into
mainfrom
close-config-files-more

Conversation

@davidanthoff

@davidanthoff davidanthoff commented Nov 2, 2025

Copy link
Copy Markdown
Collaborator

I think this probably should work because we now have a separate lock file that handles all concurrency.

WIP at the moment.

IanButterworth added a commit that referenced this pull request Jun 6, 2026
Shrink the region covered by the global juliaup configuration lock so that
the network download/extract of a new version no longer happens while the
exclusive lock is held. `juliaup add` now:

  1. takes the shared lock only briefly to check whether the channel is
     already installed, then releases it;
  2. downloads and extracts the version into a temporary directory inside
     juliauphome with NO lock held;
  3. re-acquires the exclusive lock only to atomically rename the download
     into place and update the config.

This splits the old `install_version` into `download_version_to_temp`
(lock-free, network-bound) and `commit_version_install` (lock-held, fast
rename + config write). `install_version` is retained as a thin wrapper for
existing callers.

How this honors the discussion (#435, #561):
- Implements davidanthoff's proposed design from #435: read config + release
  lock, download, then re-acquire and commit, instead of holding the write
  lock for the whole download.
- Honors LilithHafner's refinement: the commit phase re-checks whether the
  install is still needed, so two processes installing the same version in
  parallel resolve cleanly (the loser discards its temp dir) rather than
  erroring.
- Keeps StefanKarpinski's shared/exclusive model: many readers (e.g. the
  launcher checking for self-update / auto-install) coexist and only block
  for the millisecond-scale commit, not for a multi-minute download.

Benefit over the other open PRs:
- vs #1238 (remove file locking entirely, atomic-rename only): juliaup
  performs multi-file operations (install dir + config + symlinks) that a
  single-file atomic rename cannot keep mutually consistent. This change
  retains the lock for cross-file consistency while still eliminating the
  long-lock pathology that #1238 targets, addressing davidanthoff's stated
  objection to dropping the lock outright.
- vs #1317 (close config files right after read): complementary rather than
  competing — that PR shortens how long handles stay open; this PR shortens
  how long the exclusive lock is held during the expensive download. They
  compose cleanly.
IanButterworth added a commit that referenced this pull request Jun 10, 2026
Shrink the region covered by the global juliaup configuration lock so that
the network download/extract of a new version no longer happens while the
exclusive lock is held. `juliaup add` now:

  1. takes the shared lock only briefly to check whether the channel is
     already installed, then releases it;
  2. downloads and extracts the version into a temporary directory inside
     juliauphome with NO lock held;
  3. re-acquires the exclusive lock only to atomically rename the download
     into place and update the config.

This splits the old `install_version` into `download_version_to_temp`
(lock-free, network-bound) and `commit_version_install` (lock-held, fast
rename + config write). `install_version` is retained as a thin wrapper for
existing callers.

How this honors the discussion (#435, #561):
- Implements davidanthoff's proposed design from #435: read config + release
  lock, download, then re-acquire and commit, instead of holding the write
  lock for the whole download.
- Honors LilithHafner's refinement: the commit phase re-checks whether the
  install is still needed, so two processes installing the same version in
  parallel resolve cleanly (the loser discards its temp dir) rather than
  erroring.
- Keeps StefanKarpinski's shared/exclusive model: many readers (e.g. the
  launcher checking for self-update / auto-install) coexist and only block
  for the millisecond-scale commit, not for a multi-minute download.

Benefit over the other open PRs:
- vs #1238 (remove file locking entirely, atomic-rename only): juliaup
  performs multi-file operations (install dir + config + symlinks) that a
  single-file atomic rename cannot keep mutually consistent. This change
  retains the lock for cross-file consistency while still eliminating the
  long-lock pathology that #1238 targets, addressing davidanthoff's stated
  objection to dropping the lock outright.
- vs #1317 (close config files right after read): complementary rather than
  competing — that PR shortens how long handles stay open; this PR shortens
  how long the exclusive lock is held during the expensive download. They
  compose cleanly.
@IanButterworth

Copy link
Copy Markdown
Member

I think I closed this accidentally. Thought it was #746

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