-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix bug: corruption when cargo killed while writing #12744
Conversation
r? @ehuss (rustbot has picked a reviewer for you, use r? to override) |
@epage or @weihanglo, can either of you take assignment on this? |
r? epage |
If it helps. I can write a test that makes |
To make discussion more productive, I added a test that is failing around I recommend we switch to the |
Would you be up for cleaning up the commits for how you'd want them communicating out this change? |
Thanks for the feedback, and yes, I'll be cleaning and adding one more test for the "add" command. |
Thanks for continuing on this and sorry for the initial delay before I got to reviewing this! |
No worries. I know ya'll are swamped. Thanks for steering. I may be away from keyboard for several days... will return to finish. |
I think I'm done unless there's feedback on this change. Let me know @epage , thanks! |
@tompscanlan sounded like you planned to clean up the commits. Were you still planning to do that? |
I think I'm done @epage, unless we want to trim of the tests. I might take a few days to respond. |
Thanks! @bors r+ |
☀️ Test successful - checks-actions |
Update cargo 9 commits in 59596f0f31a94fde48b5aa7e945cd0b7ceca9620..794d0a82547f3081044c0aca7b6083733ce51344 2023-09-29 19:29:17 +0000 to 2023-10-03 23:19:33 +0000 - Prep for automating MSRV management (rust-lang/cargo#12767) - chore(deps): update rust crate itertools to 0.11.0 (rust-lang/cargo#12759) - fix bug: corruption when cargo killed while writing (rust-lang/cargo#12744) - Disable custom_target::custom_bin_target on windows-gnu (rust-lang/cargo#12763) - chore(deps): update compatible (rust-lang/cargo#12757) - Add more missing `strip` info to docs. (rust-lang/cargo#12754) - chore(deps): update actions/checkout action to v4 (rust-lang/cargo#12762) - chore(deps): update rust crate cargo_metadata to 0.18.0 (rust-lang/cargo#12758) - fix(test): Add back in newlines to diffs (rust-lang/cargo#12753) r? ghost
Seeing recent fialures on Windows - rust-lang#13748 - rust-lang#13738 - rust-lang#13740 and maybe more The test was added in rust-lang#12744. It seems of limited utility because there are innumerable ways of adding new writes that aren't atomic and we can't test for them all. Even this case, its limited. See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Flaky.20test.3A.20.20-death.3A.3Akill_cargo_add_never_corrupts_cargo/near/432979594
test: Remove add/remove death tests Seeing recent fialures on Windows - #13748 - #13738 - #13740 and maybe more The test was added in #12744. It seems of limited utility because there are innumerable ways of adding new writes that aren't atomic and we can't test for them all. Even this case, its limited. See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Flaky.20test.3A.20.20-death.3A.3Akill_cargo_add_never_corrupts_cargo/near/432979594
Seeing recent fialures on Windows - rust-lang#13748 - rust-lang#13738 - rust-lang#13740 and maybe more The test was added in rust-lang#12744. It seems of limited utility because there are innumerable ways of adding new writes that aren't atomic and we can't test for them all. Even this case, its limited. See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Flaky.20test.3A.20.20-death.3A.3Akill_cargo_add_never_corrupts_cargo/near/432979594
test: Remove add/remove death tests Seeing recent fialures on Windows - #13748 - #13738 - #13740 and maybe more The test was added in #12744. It seems of limited utility because there are innumerable ways of adding new writes that aren't atomic and we can't test for them all. Even this case, its limited. See also https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Flaky.20test.3A.20.20-death.3A.3Akill_cargo_add_never_corrupts_cargo/near/432979594
What does this PR try to resolve?
fix #11386, superseding #12362
How should we test and review this PR?
Added unit test showing basic equivalency to existing
write(path, content)
. Full test suite should exercise write.Added tests for cargo add and remove. These are timing tests, so take a bit of time to run. 5-10s each. They may not fail every time, but do so regularly. Making the change to these two writes seems to prevent me from failing these tests at all.
Additional information
This uses tempfile::persist which was an existing dependency. atomicwrites crate, an alternative option for this fix, indicates
tempfile::persist
is the same thing. Since we already use tempfile as a dep, I stuck with that.