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

Race when copying package files #26990

Open
vbraun opened this issue Jan 1, 2019 · 15 comments
Open

Race when copying package files #26990

vbraun opened this issue Jan 1, 2019 · 15 comments

Comments

@vbraun
Copy link
Member

vbraun commented Jan 1, 2019

There seems to be a race when copying files as cp is not atomic. I'm not sure if the copying holds a lock. Either the copying or the *.pyc file generation by the Python interpreter in another process conflicted here:

[future-0.17.1] Successfully installed future-0.17.1
[future-0.17.1] Cleaning up...
[future-0.17.1] Removed build tracker '/tmp/pip-req-tracker-ruDJcT'
[future-0.17.1] 
[future-0.17.1] real	0m4.907s
[future-0.17.1] user	0m2.226s
[future-0.17.1] sys	0m0.382s
[future-0.17.1] Copying package files from temporary location /home/chapoton/sage/local/var/tmp/sage/build/future-0.17.1/inst to /home/chapoton/sage/local
[future-0.17.1] cp: cannot create regular file '/home/chapoton/sage/local/./lib/python2.7/site-packages/future/__init__.pyc': File exists
[future-0.17.1] ************************************************************************
[future-0.17.1] Error copying files for future-0.17.1.
[future-0.17.1] ************************************************************************
[future-0.17.1] Please email sage-devel (http://groups.google.com/group/sage-devel)
[future-0.17.1] explaining the problem and including the log file
[future-0.17.1]   /home/chapoton/sage/logs/pkgs/future-0.17.1.log
[future-0.17.1] Describe your computer, operating system, etc.
[future-0.17.1] ************************************************************************

See also: https://unix.stackexchange.com/questions/116280/cannot-create-regular-file-filename-file-exists

CC: @embray

Component: build

Issue created by migration from https://trac.sagemath.org/ticket/26990

@vbraun vbraun added this to the sage-8.6 milestone Jan 1, 2019
@vbraun

This comment has been minimized.

@embray
Copy link
Contributor

embray commented Jan 2, 2019

comment:2

This is basically a duplicate of #26018, particularly #26018 comment:4, though I'm not positive if the branch there fixes it for all cases.

@embray embray removed this from the sage-8.6 milestone Jan 2, 2019
@embray embray closed this as completed Jan 2, 2019
@embray
Copy link
Contributor

embray commented Jan 2, 2019

comment:3

Actually I'm not sure this is #26018, but it still looks like a fluke. How could you get:

Error copying files for future-0.17.1.

after

Successfully installed future-0.17.1

unless somehow the same package was being installed twice simultaneously?

@vbraun
Copy link
Member Author

vbraun commented Jan 2, 2019

comment:4

The Error copying files for future-0.17.1. is just the error branch in build/bin/sage-spkg

The success message is written to stdout, and the error message to stderr. Both are independently buffered streams, it is to be expected that they are out of order.

@vbraun vbraun reopened this Jan 2, 2019
@embray
Copy link
Contributor

embray commented Jan 3, 2019

comment:5

I understand that, but the error case is:

 903     $SAGE_SUDO cp -Rp "$PREFIX/." "$SAGE_LOCAL"
 904     if [ $? -ne 0 ]; then
 905         error_msg "Error copying files for $PKG_NAME."
 906         exit 1
 907     fi

i.e. it should have exited the script before the success message was ever echoed at all.

@vbraun
Copy link
Member Author

vbraun commented Jan 3, 2019

comment:6

The first 'Successfully installed' is printed by pip, which is also why its before the 'Removed build tracker...'

@embray
Copy link
Contributor

embray commented Jan 3, 2019

comment:7

Yes, I just realized that. It's the same exact message so it's confusing. In that case I do believe this is a duplicate.

@embray
Copy link
Contributor

embray commented Jan 3, 2019

comment:8

So this is still a duplicate of #26018. The problem with the future package in particular is that it (confusingly) provides stand-ins for several packages and modules in the Python 3 stdlib, such that they end up getting imported during the build process by other packages (such as pip) that support Python 3.

So I need to update #26018 to include future in the list of "python toolchain packages" that are not installed in parallel.

@vbraun
Copy link
Member Author

vbraun commented Jul 28, 2019

comment:9

#26018 seems to have stalled

I'm also not convinced that its the right fix, imho we just shoudn't copy over pyc files for installation (they contain hardcoded absolute paths). Nothing good can come out of this.

@vbraun vbraun reopened this Jul 29, 2019
@embray
Copy link
Contributor

embray commented Aug 12, 2019

comment:11

That's a good point about the filename pyc files, but I'm not sure that's really the issue here. Besides, I believe there are ways (e.g., maybe with the compileall module) to deal with that, though I haven't tried.

#26018 doesn't appear to be stalled for any good reason. I set it to needs_review 7 months, no one did anything, and now it needs to be rebased again.

@mkoeppe
Copy link
Member

mkoeppe commented Feb 10, 2020

comment:12

Perhaps all that DESTDIR business should only apply to non-Python modules
if we arrange for all Python modules to be installed via pip.

@embray
Copy link
Contributor

embray commented Feb 12, 2020

comment:13

They are already installed with pip, and regardless I don't think that would particularly help. I think it would be annoying to have some SPKGs that use a different installation method.

When I last proposed it, #26018 solved the problem for me.

@mkoeppe
Copy link
Member

mkoeppe commented Dec 8, 2023

Closing as outdated

@mkoeppe mkoeppe closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2023
@mkoeppe mkoeppe reopened this Dec 14, 2023
@mkoeppe
Copy link
Member

mkoeppe commented Dec 14, 2023

And... the race is back.
https://github.com/sagemath/sage/actions/runs/7202678226/job/19621273004#step:11:4982

 [pari_galdata-20080411.p0]   
  [pari_galdata-20080411.p0]   real	0m0.097s
  [pari_galdata-20080411.p0]   user	0m0.030s
  [pari_galdata-20080411.p0]   sys	0m0.067s
  [pari_galdata-20080411.p0]   Moving package files from temporary location /sage/local/var/tmp/sage/build/pari_galdata-20080411.p0/inst to /sage/local
  [pari_galdata-20080411.p0]   cp: cannot create directory '/sage/local/./share/pari': File exists
  [pari_galdata-20080411.p0]   ************************************************************************
  [pari_galdata-20080411.p0]   Error moving files for pari_galdata-20080411.p0.
  [pari_galdata-20080411.p0]   ************************************************************************
  [pari_galdata-20080411.p0] Full log file: /sage/logs/pkgs/pari_galdata-20080411.p0.log

@mkoeppe
Copy link
Member

mkoeppe commented Feb 15, 2024

Another one https://github.com/mkoeppe/sage/actions/runs/7911709009/job/21596294450#step:11:8815

  [python3-3.11.1]   Installing valgrind suppression file...
  [python3-3.11.1]   Misc/valgrind-python.supp -> /sage/local/var/lib/sage/venv-python3.11.1/var/tmp/sage/build/python3-3.11.1/inst/sage/local/lib/valgrind/python3.supp
  [python3-3.11.1]   
  [python3-3.11.1]   real	1m6.187s
  [python3-3.11.1]   user	0m37.902s
  [python3-3.11.1]   sys	0m5.167s
  [python3-3.11.1]   Moving package files from temporary location /sage/local/var/lib/sage/venv-python3.11.1/var/tmp/sage/build/python3-3.11.1/inst to /sage/local/var/lib/sage/venv-python3.11.1
  [python3-3.11.1]   cp: cannot create directory '/sage/local/var/lib/sage/venv-python3.11.1/./lib/python3.11/__pycache__': File exists
  [python3-3.11.1]   ************************************************************************
  [python3-3.11.1]   Error moving files for python3-3.11.1.
  [python3-3.11.1]   ************************************************************************
  [python3-3.11.1] Full log file: /sage/logs/pkgs/python3-3.11.1.log
make[2]: *** [Makefile:3387: python3-SAGE_VENV-no-deps] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants