Skip to content

Bootstrap: Try renaming the file if removing fails#127152

Merged
bors merged 2 commits into
rust-lang:masterfrom
ChrisDenton:rename
Jul 2, 2024
Merged

Bootstrap: Try renaming the file if removing fails#127152
bors merged 2 commits into
rust-lang:masterfrom
ChrisDenton:rename

Conversation

@ChrisDenton

@ChrisDenton ChrisDenton commented Jun 30, 2024

Copy link
Copy Markdown
Member

Second attempt at working around #127126

If we can't remove the file, then try renaming it. This will leave the destination path free to use.

try-job: x86_64-msvc-ext

@rustbot

rustbot commented Jun 30, 2024

Copy link
Copy Markdown
Collaborator

r? @onur-ozkan

rustbot has assigned @onur-ozkan.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jun 30, 2024
@ChrisDenton

Copy link
Copy Markdown
Member Author

@bors try

bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 30, 2024
Bootstrap: Try renaming the file if removing fails

Second attempt at working around rust-lang#127126

If we can't remove the file, then try renaming it. This will leave the destination path free to use.

try-job: x86_64-msvc-ext
@bors

bors commented Jun 30, 2024

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 17a169c with merge 732189e...

@bors

bors commented Jun 30, 2024

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: 732189e (732189e67760492d47e62302dad40e09af01efd6)

@ChrisDenton

Copy link
Copy Markdown
Member Author

Try build succeeded but considering the failure is intermittent that's doesn't prove this fixes the issue. Still, it's a good sign. I've just tied up the code a bit so I think this is ready for review.

@onur-ozkan

Copy link
Copy Markdown
Contributor

AFAIK it's not possible to rename locked files on Windows.

@ChrisDenton

ChrisDenton commented Jul 2, 2024

Copy link
Copy Markdown
Member Author

The file is almost certaibly only locked because it's still being executed. That type of lock allows renames but not deletes (specifically it's locked due to a memory map, not due to FILE_SHARE).

@ChrisDenton

Copy link
Copy Markdown
Member Author

Incidentally this can be trivially demonstrated on a Windows machine by this program:

fn main() {
    let exe = std::env::current_exe().unwrap();
    std::fs::rename(&exe, "moved.exe").unwrap();
}

That is, an application the renames itself while it is running.

@onur-ozkan onur-ozkan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

r=me with the nit fix

Comment thread src/bootstrap/src/lib.rs
Comment on lines +1680 to +1687
if let Err(e) = fs::remove_file(dst) {
if e.kind() != io::ErrorKind::NotFound {
// workaround for https://github.com/rust-lang/rust/issues/127126
// if removing the file fails, attempt to rename it instead.
let now = t!(SystemTime::now().duration_since(SystemTime::UNIX_EPOCH));
let _ = fs::rename(dst, format!("{}-{}", dst.display(), now.as_nanos()));
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like a good use case #[cfg(windows)].

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I used cfg!(windows) if that's alright as it's easier to integrate.

@ChrisDenton

Copy link
Copy Markdown
Member Author

@bors r=onur-ozkan rollup

@bors

bors commented Jul 2, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit b998cff has been approved by onur-ozkan

It is now in the queue for this repository.

@bors

bors commented Jul 2, 2024

Copy link
Copy Markdown
Collaborator

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 2, 2024
@Kobzol

Kobzol commented Jul 2, 2024

Copy link
Copy Markdown
Member

Let's make this a higher priority, as it can help alleviating spurious CI failures.

@bors p=10

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 2, 2024
Bootstrap: Try renaming the file if removing fails

Second attempt at working around rust-lang#127126

If we can't remove the file, then try renaming it. This will leave the destination path free to use.

try-job: x86_64-msvc-ext
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 2, 2024
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#126883 (Parenthesize break values containing leading label)
 - rust-lang#127136 (Fix `FnMut::call_mut`/`Fn::call` shim for async closures that capture references)
 - rust-lang#127146 (Uplift fast rejection to new solver)
 - rust-lang#127152 (Bootstrap: Try renaming the file if removing fails)
 - rust-lang#127168 (Use the aligned size for alloca at args/ret when the pass mode is cast)
 - rust-lang#127203 (Fix import suggestion error when path segment failed not from starting)
 - rust-lang#127212 (Update books)
 - rust-lang#127224 (Make `FloatTy` checks exhaustive in pretty print)
 - rust-lang#127230 (chore: remove duplicate words)
 - rust-lang#127243 (Add test for adt_const_params)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors

bors commented Jul 2, 2024

Copy link
Copy Markdown
Collaborator

⌛ Testing commit b998cff with merge 49ff390...

@bors

bors commented Jul 2, 2024

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: onur-ozkan
Pushing 49ff390 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 2, 2024
@bors bors merged commit 49ff390 into rust-lang:master Jul 2, 2024
@rustbot rustbot added this to the 1.81.0 milestone Jul 2, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 2, 2024
…iaskrgr

Rollup of 10 pull requests

Successful merges:

 - rust-lang#126883 (Parenthesize break values containing leading label)
 - rust-lang#127136 (Fix `FnMut::call_mut`/`Fn::call` shim for async closures that capture references)
 - rust-lang#127146 (Uplift fast rejection to new solver)
 - rust-lang#127152 (Bootstrap: Try renaming the file if removing fails)
 - rust-lang#127168 (Use the aligned size for alloca at args/ret when the pass mode is cast)
 - rust-lang#127203 (Fix import suggestion error when path segment failed not from starting)
 - rust-lang#127212 (Update books)
 - rust-lang#127224 (Make `FloatTy` checks exhaustive in pretty print)
 - rust-lang#127230 (chore: remove duplicate words)
 - rust-lang#127243 (Add test for adt_const_params)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (49ff390): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (secondary -5.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.1% [-5.7%, -3.5%] 9
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 696.686s -> 695.727s (-0.14%)
Artifact size: 327.51 MiB -> 327.59 MiB (0.02%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

spurious ci failure: The process cannot access the file because it is being used by another process

6 participants