-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Bug: running 2 (maybe more) yarn commands on different projects the same time fails #683
Comments
Confirmed. $ node -v
v5.7.1
$ yarn -v Edit: Now I am just stuck in this state. |
This bug has to be resolved in order to make Lerna compatible with Yarn, because Lerna spawns multiple concurrent processes of |
@timche Thanks for the update. I'll check it out again tonight. |
@moneytree-doug I think you might have misunderstood what he said. He didn't say that it |
@steelbrain Haha, whoops! |
I ended up with a partially written file in |
Adding my case here since we're in a similar situation, with multiple yarn instances running concurrently. In my case the error I got was |
Seeing this as well if Jenkins happens to run multiple builds at the same time. The error is very short:
|
It seems the intended "solution" is to use This effectively turns off concurrency completely, which I find rather ridiculous, but maybe preferable to complete crash? Also, the default location of the mutex is NOT the location of the cache (which would make sense, since it is access to this cache that it is guarding) but the current working directory, where you are probably alone anyway. So you have to come up with your own unique location of the mutex file, and agree on that with all your other users, otherwise it won't help. Apart from a global mutex being an "interesting" solution to implement a concurrency safe cache, one can only wonder why this isn't enabled by default, and with a sensible default location as well... |
There's - - mutex network, which works globally. Good for use in CI
environments but unfortunately undocumented.
…On Dec 19, 2016 6:30 AM, "marc-guenther" ***@***.***> wrote:
It seems the intended "solution" is to use --mutex option to yarn:
- https://yarnpkg.com/en/docs/cli/#toc-concurrency-and-mutex
This effectively *turns off concurrency completely*, which I find rather
ridiculous, but maybe preferable to complete crash?
Also, the *default location* of the mutex is NOT the location of the
cache (which would make sense, since it is access to this cache that it is
guarding) but the *current working directory*, where you are probably
alone anyway.
So you have to come up with your own unique location of the mutex file,
and agree on that with all your other users, otherwise it won't help.
Apart from a global mutex being an "interesting" solution to implement a
concurrency safe cache, one can only wonder why this isn't enabled by
default, and with a sensible default location as well...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#683 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABJFPz_goDBKU9WuHogr_boD_Uhack0vks5rJnjtgaJpZM4KT7sH>
.
|
Looks like the |
Isn't that the link I posted? :)
We have some projects that set their own cache location, and as such would not be affected by the concurrency issue. Setting this option globally would mean they cannot run in parallel to others anymore. None of this would be a problem if the |
It would be great to set the default behaviour via env variable. So one doesn't need to specify it on every task of the CI server. |
References: yarnpkg/yarn#683
* chore(lerna): Fix lerna packaging and travis config * Moves generator into packages folder * Moves containers into packages folder * Fix lerna travis build * Fixes travis * Fixes yarn issues References: yarnpkg/yarn#683
It should be possible to allow for concurrency (on at least UNIX) here if each yarn processes creates a cache entry in a directory with a randomized name and then creates a symlink to it. Races between processes should then be harmless (just leaving an orphaned directory around if lose). Need the symlinks since directory renames aren't atomic. http://stackoverflow.com/questions/307437/moving-a-directory-atomically It would be simpler if could use files in the cache, not directories, but maybe that's not viable or performant. Creating node_modules/ dirs is almost always going to be on the critical path on test servers running things concurrently, so allowing concurrency here would be desirable. Putting all the cache entries in one directory will fail to scale properly with a sufficiently large number of npm package versions, so might want to split across multiple directories too (directory creation should be easy to make work concurrently). How would existing caches be migrated to a new format safely? Could use a new independent cache dir, subdir or naming scheme, though this would make people download all cache entries again. If don't add extra directories, could allow a mixture of dirs and symlinks. If a dir already exists, nothing would want to replace it with a symlink, so there's no timing issue. If do add extra sub directories, could symlink to the old top-level directories where necessary. |
I get this exact same error, but my use case is slightly different: On Jenkins, I get this message with Yarn > I'm only running 1 Jenkins job, and I clean the workspace each time.
These options appear to have no effect on the outcome: Fails
Fails
Passes
|
we see this too, even if using the mutex option. if any attempt at using this is super annoying, is there any way to debug this? |
This problem needs to be adressed, badly. Running parallel jenkins builds that invoke yarn is highly problematic at the moment. We tried mutexes, we tried to redirect the yarn cache to the build directory, but nothing helped. There seems to be some part of yarn that always accesses a global location, and that access isn't safe for concurrency. |
Which version are you using? Starting from the 1.0, we made a few changes on the mutex codebase that might solve your issues. |
We're on 1.0.2. We are running Jenkins declarative Pipelines, which call Gradle, which in turn uses the Gradle Node Plugin in order to execute the yarn tasks . The yarn install task in my gradle looks like this:
So what is executed is An unexpected error occurred: "https://registry.yarnpkg.com/core-js/-/core-js-2.5.0.tgz: ENOENT: no such file or directory, utime '/home/user/.cache/yarn/v1/npm-core-js-2.5.0-569c050918be6486b3837552028ae0466b717086/library/fn/math/rad-per-deg.js'" (the offending JS file varies). The interesting part is that yarn attempts to open something in I currently cannot eliminate the possibility that the gradle node plugin has a bug, or is interfering in any way here. However, as Yarn integrates with all popular build servers except for Jenkins, we have little choice. An official yarn gradle plugin would be nice too. |
I think there's an error in your code. Have you tried using
instead of
? |
... interesting point. Will give it a try, thanks! |
@MartinHaeusler as a workaround you may also try using a separate cache folder for each invocation. That would trade space for time (mutex makes other instances wait for each other). |
Unfortunately the fix proposed by @arcanis (even though it was a nice hint!) did not change the situation. |
That's really weird 😯 We use Yarn internally at fb, and as you can imagine we do have a fair amount of parallel tests running with the network mutex, so I have no idea why it doesn't work on your side. |
I am suspecting the gradle node plugin by now which runs our yarn tasks to be at fault here... This issue will be one tough nut to crack. |
@MartinHaeusler may be run Yarn with |
Nice suggestion, I'll give it a shot. Somehow I suspect that either the gradle node plugin does not properly pass the |
By the way, apparently I'm not the only one struggling with this problem on Jenkins: |
I feel like we can close this. Objections? @MartinHaeusler @neophob or anyone else? |
Being able to corrupt the cache if run yarn concurrently with itself using its default options is a bug. Using a sensible default for --mutex (i.e. a per-cache-folder path) or reimplementing cache so that it doesn't need a mutex would solve this (see my above comments for how this might be possible). |
Close this? Has it been fixed in a different ticket? Cause I haven't seen anything here. What's the fix? |
Correct, and we will happily review and merge any PR that would help with that.
Using the |
ah, the best kind of QA: sweep it under the rug ;-) |
Yes, it is completely ridiculous. First ignore the bug for a year, then suddenly close it without any fix, because there is a horrible workaround (which existed the entire time!), which everyone has to enable manually every time. Ah, and most important, don't bother to update the documentation. |
Yarn is an open-source and community-driven project, which means that by design you're just as welcome to contribute to it as you are to use it. The documentation is here, the source code here. If you feel strongly about this feature, please feel free to give it a try - we'll happily spend time reviewing it and giving you pointers to unblock you if you have questions. |
@Spongman @marc-guenther I am sorry that you feel this way about the issue, and Yarn in general. That said we have documented this command line flag some time ago with yarnpkg/website#280. I am not claiming it is the most visible or best description but at least it is there, searchable, and anyone who feels differently is welcome to try improving it. It is actually best for people like you who feel frustrated and not served well by the project to take a stab at improving docs because you know exactly where the pain is. Regarding fixing the root cause of the issue, which is unsafe concurrent read/write access to a global cache, I agree that this should be solved. That said, anyone who tried to fix this would also know that it is not an easy problem to solve, especially if you don't want to compromise performance. Moreover, concurrent Yarn instances do not seem to be the common case since people usually work on a single project at a time (at least install dependencies one project at a time) and CI systems are isolating builds (with some exceptions). This is why the issue hasn't received much attention from the core maintainers. That said if you feel strongly about it and if you have a good solution in mind, we would be more than happy to assist you throughout the contribution process and champion your pull request if you decide to submit one. Thanks a lot for sharing your concerns again. All being said I'd also appreciate if you keep in mind that we are all working towards better software here and the best way to get there is collaboration instead of blaming. I'd love to continue this discussion without pinging everyone on this thread continuously so feel free to join our Discord server and ping me directly or on any of the channels. I'd love to hear more about why you feel your contributions are not welcome and do our best to resolve them ❤️ |
I installed yarn the first time, then i ran
yarn
on project A, seconds later I ranyarn
on project B.Both installation failed, project A output:
project B output:
When I run those commands sequentially it works as expected.
versions:
The text was updated successfully, but these errors were encountered: