-
Notifications
You must be signed in to change notification settings - Fork 2k
Log to temp files then rename #1351
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼 logic looks sound. Verified this fixes #1323 locally as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fix for a single symptom of a larger issue. It solves for the fact that our method of moving logs into the cache is:
- Write the log file into the package directory at a consistent location (e.g.
examples/basic/apps/docs/.turbo/turbo-build.log
) - Add the path to the package outputs.
- Move all the contents into the cache via hardlinks.
On a second run of the same task, since the file is in a consistent location, it writes the log to the same path which is hardlinked to an existing cache. This issue will show up every time.
This issue is just an instance of a larger problem we encounter with using hardlinks. Any time time a task is re-run and the task itself does not, say, remove the paths that it outputs to first (breaking the hardlinks on our behalf) it can pollute any number of previous local caches when writing to the same output paths.
I don't believe that trying to play whack-a-mole with breaking hardlinks is a sustainable solution. Even if we properly break hardlinks in our own code that doesn't preclude a user accidentally polluting their cache by modifying something manually.
Given that, I don't believe that we should take this approach to solving the problem. I have opened #1354 with an alternate proposal which I believe addresses the root of the problem with the smallest possible change.
Log files are hard-linked into the cache, so when re-running a task we need to ensure we don't pollute a previous run.
This changes our logging to stream to a temp file, which we then rename to the actual log file. This serves to break the hard link.
Note that:
Fixes #1323