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

WIP: wrap: Implemented wraplock #13784

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

sp1ritCS
Copy link
Contributor

@sp1ritCS sp1ritCS commented Oct 12, 2024

Mostly a POC looking for feedback, but:

As I've described in #13758

When you start multiple meson setup instances at the same time, then during their attempted access of the same subproject, one instance manages to start the download, while the other attempts to evaluate a partially download subproject: ../meson.build:406:17: ERROR: Subproject exists but has no meson.build file.

The current implementation is a heavily shortend/modified version of tox-dev:filelock/UnixFileLock. The issue with the current code is hower, that fcntl isn't cross-platform.

Unlike the filelock package, I was thinking of just providing the fnctl locking implementation and letting meson processes race into each other of systems that don't implement it.

mesonbuild/wrap/wraplock.py Fixed Show fixed Hide fixed
mesonbuild/wrap/wraplock.py Fixed Show fixed Hide fixed
mesonbuild/wrap/wraplock.py Fixed Show fixed Hide fixed
mesonbuild/wrap/wraplock.py Fixed Show fixed Hide fixed
mesonbuild/wrap/wraplock.py Fixed Show fixed Hide fixed
mesonbuild/wrap/wraplock.py Fixed Show fixed Hide fixed
mesonbuild/wrap/wraplock.py Fixed Show fixed Hide fixed
mesonbuild/wrap/wraplock.py Fixed Show fixed Hide fixed
mesonbuild/wrap/wraplock.py Fixed Show fixed Hide fixed
To avoid raceconditions, where one instance of meson currently downloads
a subproject defined in a wrapfile, while another either
  a. starts the download itself too
  b. attemts to evaluate the partially downloaded subproject
wraplock introduces a lockfile, which should prevent simultaneous access
of subprojects by wrap between different instances of meson.
This is used when fnctl is not found. In these cases there will be no
guarding of subprojects and multiple meson instances may still run into
eachother.
@eli-schwartz
Copy link
Member

The current implementation is a heavily shortend/modified version of tox-dev:filelock/UnixFileLock. The issue with the current code is hower, that fcntl isn't cross-platform.

Unlike the filelock package, I was thinking of just providing the fnctl locking implementation and letting meson processes race into each other of systems that don't implement it.

See mesonbuild/utils/platform.py and posix.py / win32.py -- we have an existing locker and it supports msvcrt.

return;
# Do not remove the lockfile:
# https://github.com/tox-dev/py-filelock/issues/31
# https://stackoverflow.com/questions/17708885/flock-removing-locked-file-without-race-condition
Copy link
Member

Choose a reason for hiding this comment

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

Do you need to create a file? IIRC you can os.open(subdir_root, os.O_RDONLY) and lock it. Would that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

flock should work with directories, but for potability reasons (mostly orienting on what filelock did) files are better.

@sp1ritCS
Copy link
Contributor Author

@eli-schwartz platform.py provides BuildDirLock, which is fairly specific.

Should I rewrite BuildDirLock into a more generic lock and implement BuildDirLock then ontop of the generic one?

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.

3 participants