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

Recommendation to switch fs-extra for an alternate implementation. #8569

Merged
merged 8 commits into from
Apr 6, 2017

Conversation

abernix
Copy link
Contributor

@abernix abernix commented Apr 6, 2017

This proposes reverting/replacing #8491, which has been problematic in the 1.4.4 series of RCs, specifically on Windows. More so, I believe that fs-extra could be overboard and we could go with a much more simple implementation to accomplish the goal of fixing cross-device copies.

Unfortunately, fs-extra is still not as perfect at handling various file system conditions as would be ideal. It seemed sensical to try and use a library like this, however it turns out that the Meteor suite of file system functions performs better on Windows. For example, fs-extra still tries to create symlinks as an unprivileged user – a forbidden task on Windows unless running as Administrator.

In addition, I ran into a constant stream of other errors: ENOTEMPTY, EBUSY, EEXIST and EPERM (on an open, no less) – all for various, Windows-only (from what I can gather) reasons.

My current recommendation is that we remove fs-extra and replace the Builder#complete renameDirAlmostAtomically call (which does not absolutely have to be done atomically; "fast" is the goal) with a try/catch which resorts to a basic copy if err.code === 'EXDEV'. All other functionality stays the same.

I've crudely implemented it with 523c7ce but would be open to other suggestions.

This reverts commits:

/cc @jshimko

abernix added 2 commits April 6, 2017 06:50
…n docker builds. (meteor#8491)"

Unfortunately, `fs-extra` is still not as perfect at handling various
file system conditions as would be ideal.  It seemed sensical to try and
use a library like this however, it turns out that the Meteor suite
of file system functions stands up best on Windows, which is where I
encountered most problems.

For example, `fs-extra` still tries to create symlinks as an unprivileged
user – a forbidden task on Windows unless running as Administrator.

In addition, I ran into a constant stream of other errors: `ENOTEMPTY`,
`EBUSY`, `EEXIST` – all for various reasons.

My current recommendation is that we remove `fs-extra` and replace the
`Builder#complete` `renameDirAlmostAtomically` call (which does not
absolutely _have_ to be done atomically) with a `try`/`catch` which
resorts to a basic copy if `err.code === 'EXDEV'`.  All other
functionality stays the same.

This reverts commits:

* d49f3e2
* 3257baf
* 74cb8eb
* 5bbdcc9
* 6a0767b
This operation does not have to be done atomically and this should allow
cross-device copies to be made if necessary.
@abernix abernix requested a review from benjamn April 6, 2017 04:35
@@ -687,7 +687,16 @@ Previous builder: ${previousBuilder.outputPath}, this builder: ${outputPath}`
// case of renameDirAlmostAtomically since that one is constructing files to
// be checked in to version control, but here we could get away with it.
if (this.buildPath !== this.outputPath) {
files.renameDirAlmostAtomically(this.buildPath, this.outputPath);
try {
files.rename(this.buildPath, this.outputPath);
Copy link
Contributor Author

@abernix abernix Apr 6, 2017

Choose a reason for hiding this comment

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

This portion was just a proposal. This is failing because the renames and rm_recursives from renameDirAlmostAtomically are necessary to make way for the incoming tree.

As a thought, maybe we should continue to use renameDirAlmostAtomically here instead of rename, and just catch the EXDEV.

abernix added 2 commits April 6, 2017 17:17
The `rename` is not sufficient on its own since it won't pave the way
for the new directory by ensuring that it's empty first.

`renameDirAlmostAtomically` will do that.
This also makes it possible to disable it in places where we were not
checking against the `METEOR_DISABLE_FS_FIBERS` env. variable, like in
`rm_recursive`.
} catch (e) {
if (e.code === "EXDEV") {
files.rm_recursive(this.outputPath);
files.cp_r(this.buildPath, this.outputPath);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's move this logic into files.renameDirAlmostAtomically, as discussed offline.

abernix added 3 commits April 6, 2017 19:30
 ...Versus reassigning them immediately after.

 (Whitespace-only view is recommended, due to indentation change)
This logic is now handled in `files.renameDirAlmostAtomically`.

// ... and take out the trash.
if (cleanupGarbage) {
files.rm_recursive(garbageDir);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remember that we could do this cleanup asynchronously.

Copy link
Contributor Author

@abernix abernix Apr 6, 2017

Choose a reason for hiding this comment

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

Yup, thanks! Done with ae35f13!

@abernix abernix merged commit d6665e7 into meteor:release-1.4.3.x Apr 6, 2017
@abernix abernix deleted the abernix/revert-fs-extra branch April 6, 2017 18:14
benjamn pushed a commit that referenced this pull request Apr 6, 2017
PR #8569 by @abernix undid the changes this bullet point was referring to.
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