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

build-runfiles: remove temporary file prior to creating it #19241

Conversation

EdSchouten
Copy link
Contributor

When building with Remote Output Service, bb_clientd has the ability to restore snapshots of previous bazel-out/ directories. Though the file contents of these snapshots are identical to what's created in the past, the files will be read-only. This is because the files may be shared by multiple snapshots.

We have noticed that most of Bazel is fine with that. Most of the times Bazel is a good citizen, where it removes any files before recreating them. We did notice a very rare case where build-runfiles tries to make in-place modifications to a temporary file that it maintains. This change ensures that build-runfiles stops doing this.

@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Aug 14, 2023
@sgowroji sgowroji added the team-Remote-Exec Issues and PRs for the Execution (Remote) team label Aug 14, 2023
@EdSchouten EdSchouten force-pushed the eschouten/20230814-runfiles-tempfile branch from 4990fca to b718830 Compare August 14, 2023 14:53
EdSchouten added a commit to EdSchouten/bazel that referenced this pull request Aug 14, 2023
This change is the same in spirit to bazelbuild#19241. When using Bazel in
combination with bb_clientd, bb_clientd may restore a copy of bazel-out/
from a snapshot. Files restored from the snapshot are not mutable, as
they may be backed by other snapshots, a remote CAS, etc. etc. etc..

This change extends atomicallyWriteTo() to always write contents into a
new file that is guaranteed to be writable. The logic that's added here
is merely copy-pasted from what's already present at the bottom of the
same function.
When building with Remote Output Service, bb_clientd has the ability to
restore snapshots of previous bazel-out/ directories. Though the file
contents of these snapshots are identical to what's created in the past,
the files will be read-only. This is because the files may be shared by
multiple snapshots.

We have noticed that most of Bazel is fine with that. Most of the times
Bazel is a good citizen, where it removes any files before recreating
them. We did notice a very rare case where build-runfiles tries to make
in-place modifications to a temporary file that it maintains. This
change ensures that build-runfiles stops doing this.
@EdSchouten EdSchouten force-pushed the eschouten/20230814-runfiles-tempfile branch from b718830 to 90d56d5 Compare August 31, 2023 07:27
EdSchouten added a commit to EdSchouten/bazel that referenced this pull request Aug 31, 2023
This change is the same in spirit to bazelbuild#19241. When using Bazel in
combination with bb_clientd, bb_clientd may restore a copy of bazel-out/
from a snapshot. Files restored from the snapshot are not mutable, as
they may be backed by other snapshots, a remote CAS, etc. etc. etc..

This change extends atomicallyWriteTo() to always write contents into a
new file that is guaranteed to be writable. The logic that's added here
is merely copy-pasted from what's already present at the bottom of the
same function.
@tjgq tjgq added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Aug 31, 2023
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Aug 31, 2023
@brentleyjones
Copy link
Contributor

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Aug 31, 2023
@iancha1992
Copy link
Member

@bazel-io fork 6.4.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Aug 31, 2023
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Aug 31, 2023
When building with Remote Output Service, bb_clientd has the ability to restore snapshots of previous bazel-out/ directories. Though the file contents of these snapshots are identical to what's created in the past, the files will be read-only. This is because the files may be shared by multiple snapshots.

We have noticed that most of Bazel is fine with that. Most of the times Bazel is a good citizen, where it removes any files before recreating them. We did notice a very rare case where build-runfiles tries to make in-place modifications to a temporary file that it maintains. This change ensures that build-runfiles stops doing this.

Closes bazelbuild#19241.

PiperOrigin-RevId: 561615005
Change-Id: I8ca95c7d35df8a53af8f632b10b4a6141d180631
iancha1992 pushed a commit that referenced this pull request Aug 31, 2023
…19386)

When building with Remote Output Service, bb_clientd has the ability to
restore snapshots of previous bazel-out/ directories. Though the file
contents of these snapshots are identical to what's created in the past,
the files will be read-only. This is because the files may be shared by
multiple snapshots.

We have noticed that most of Bazel is fine with that. Most of the times
Bazel is a good citizen, where it removes any files before recreating
them. We did notice a very rare case where build-runfiles tries to make
in-place modifications to a temporary file that it maintains. This
change ensures that build-runfiles stops doing this.

Closes #19241.

Commit
357fc5f

PiperOrigin-RevId: 561615005
Change-Id: I8ca95c7d35df8a53af8f632b10b4a6141d180631

Co-authored-by: Ed Schouten <eschouten@apple.com>
@iancha1992
Copy link
Member

The changes in this PR have been included in Bazel 6.4.0 RC1. Please test out the release candidate and report any issues as soon as possible. If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=last_rc.
Thanks!

copybara-service bot pushed a commit that referenced this pull request Oct 6, 2023
This change is the same in spirit to #19241. When using Bazel in combination with bb_clientd, bb_clientd may restore a copy of bazel-out/ from a snapshot. Files restored from the snapshot are not mutable, as they may be backed by other snapshots, a remote CAS, etc. etc. etc..

This change extends atomicallyWriteTo() to always write contents into a new file that is guaranteed to be writable. The logic that's added here is merely copy-pasted from what's already present at the bottom of the same function.

Closes #19243.

PiperOrigin-RevId: 571276901
Change-Id: I3963ad6218e1557271c2bb4de94e89538ff512af
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Remote-Exec Issues and PRs for the Execution (Remote) team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants