-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
Remove DESTDIR staging for Python packages to eliminate race conditions during Python package installations #29585
Comments
comment:1
Various fixes are possible here:
|
comment:2
In general, I think that package installation can't be atomic, since we need to move things to SAGE_LOCAL/lib and SAGE_LOCAL/include, and we can't just create a directory temp/lib and move it to SAGE_LOCAL without overwriting the existing one. But maybe this could work with Python packages. Rewrite |
comment:3
Yes, I mean specifically for Python packages. |
comment:4
Replying to @jhpalmieri:
I think the copy-from-staging-dir code could just deal with the Python directories specially. We are working around another problem (lib64) with that code already anyway. This would solve it even for Python packages that are not installed using pip currently (#29500). |
comment:5
In fact (when |
comment:6
Something like the following (rough draft, untested)? diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg
index 5cdd55db3f..0f8acf9b97 100755
--- a/build/bin/sage-spkg
+++ b/build/bin/sage-spkg
@@ -946,6 +946,12 @@ if [ -d "$SAGE_DESTDIR" ]; then
# Generate installed file manifest
FILE_LIST="$(cd "$PREFIX" && find . -type f -o -type l | sed 's|^\./||' | sort)"
+ if [ -d "$PREFIX"/lib/python*/site-packages/ ]; then
+ echo "This is a Python package: moving site-package directories atomically."
+ SITE_PACKAGES=$(python -c 'import site; print(site.getsitepackages()[0])')
+ $SAGE_SUDO mv "$PREFIX"/lib/python*/site-packages/* "$SITE_PACKAGES"
+ fi
+
# Copy files into $SAGE_LOCAL
$SAGE_SUDO cp -Rp "$PREFIX/." "$SAGE_LOCAL"
if [ $? -ne 0 ]; then |
comment:7
Replying to @jhpalmieri:
Thanks for the pointer. The
That could work, but I think I would prefer the more general solution. |
comment:8
This could be done in some 20 lines of code I guess that would take care of getting the intended concurrency semantics right. Basically try to move a source directory to the target, handling EEXIST and in that case recursing instead. |
comment:9
The new script would also
|
comment:10
Reference: https://rcrowley.org/2010/01/06/things-unix-can-do-atomically.html |
comment:11
Ha, yes, I stumbled on that website, too. |
This comment has been minimized.
This comment has been minimized.
comment:14
I think this sort of issue was solved a long time ago with Unfortunately, with the switch to the DESTDIR system, while this is probably still helpful, it doesn't help during copying of files into SAGE_LOCAL. Perhaps the pip-lock should also be held when copying packages into $SAGE_LOCAL (don't even bother checking if it's an actual Python package; just prevent copying anything into $SAGE_LOCAL without holding the pip-lock). |
comment:15
In 9.3 I hope to switch installation of all Python packages from DESTDIR to use pip wheel - see #29500. |
This comment has been minimized.
This comment has been minimized.
comment:18
Hoping we can make progress on this ticket this week - https://wiki.sagemath.org/days111 |
Changed keywords from none to sd111 |
comment:19
Setting new milestone based on a cursory review of ticket status, priority, and last modification date. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Branch pushed to git repo; I updated commit sha1. New commits:
|
Commit: |
Author: Matthias Koeppe |
This comment has been minimized.
This comment has been minimized.
comment:27
The changes make sense, but it's hard for me to test them because I can't reproduce the race conditions. I've tried |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:30
Replying to @jhpalmieri:
Yes, exactly |
comment:31
Replying to @jhpalmieri:
Based on the failing runs that I have seen on GH Actions, I would estimate 1 in 30 to 1 in 200 runs fail... In any case, there's another reason why we should make this change: Whenever a user uses |
comment:32
Not for this ticket, but I really don't like the warning message here (when running
For this ticket: if I do I also tried |
comment:33
Replying to @jhpalmieri:
|
comment:34
Replying to @jhpalmieri:
No, I don't think so. Neither our current build system (before the present ticket) nor (Reinstallation of packages depending on |
comment:35
Replying to @jhpalmieri:
I think this warning will only show up if you switch between branches with and without this ticket. |
comment:36
Is |
comment:37
Replying to @jhpalmieri:
I don't know, but we do not depend on it to be because we are holding a lock while installing a wheel, in |
Reviewer: John Palmieri |
comment:38
Okay, let's merge it so it gets more testing. |
comment:39
Thanks! |
Changed branch from u/mkoeppe/more_race_conditions_with_python_package_installations_because_of_destdir to |
comment:41
A crucial commit was missing on this branch. Follow-up in #32361. |
Changed commit from |
comment:42
I'm at peace with this solution :) |
Follow-up from #26018:
Declaring some Python packages as PYTHON_TOOLCHAIN helped somewhat, but there are more race conditions with the same failure mechanism: Some Python package byte-compiles modules from a half-installed package, and then finishing the installation of that fails.
Of course, the high parallelization in my automatic runs on GitHub provoke these kinds of errors. But this should be fixed nevertheless.
See https://github.com/mkoeppe/sage/runs/618645992
Another occurrence on Cygwin: https://github.com/mkoeppe/sage/runs/638920131?check_suite_focus=true
Another occurrence: #30831
A new one thanks to recent
pip
's opportunistic use oftornado
:https://github.com/sagemath/sage/runs/2879682001
In this ticket, we remove the
DESTDIR
staging for Python packages. It has been redundant since we moved to installing packages via wheels.After this change, the only file that is tracked in
$SAGE_LOCAL/var/lib/sage/installed/pynormaliz-2.14
is the wheel file:Uninstalling Python packages is now done via
pip
, by means of a new removal script calledspkg-piprm
installed in$SAGE_LOCAL/var/lib/sage/scripts/SPKG/
.CC: @jhpalmieri @dimpase @embray @kliem
Component: build
Keywords: sd111
Author: Matthias Koeppe
Branch:
c3eeb69
Reviewer: John Palmieri
Issue created by migration from https://trac.sagemath.org/ticket/29585
The text was updated successfully, but these errors were encountered: