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

Improve handling of inconsistent immutable workspaces #28503

Merged
merged 10 commits into from
Mar 19, 2024

Conversation

lptr
Copy link
Member

@lptr lptr commented Mar 19, 2024

Improves #28475

Previously when we detected an inconsistent immutable workspace, we'd fail the build. Now instead we attempt to move the offending workspace to a temporary location, and re-try re-creating the content. When this happens, the following deprecation warning is produced:

> Transform lib1.jar (project :lib) with Duplicator
The contents of the immutable workspace '...' have been modified. This behavior has been deprecated. This will fail with an error in Gradle 9.0. These workspace directories are not supposed to be modified once they are created. The modification might have been caused by an external process, or could be the result of disk corruption. The inconsistent workspace has been moved to '...', and will be recreated.
outputDirectory:
 - transformed (Directory, 7cfc7dbc0901a39cf9a5f44f7ea491b8)
   - 0 (Directory, 78af062fd74d95b8d382f5adabb136f5)
     - lib1-green.jar (RegularFile, 1ba4170a71868b572bca2e747af7a707)
   - tamper-tamper.txt (RegularFile, c2a9b87422fcb39f4f55ff182939992b)

resultsFile:
 - results.bin (RegularFile, 44ec6391aaade3532e59b1d99d292b4d)

This makes the build more resilient against consistency problems caused by disk corruption, or external processes making changes to the workspaces.

In a separate PR we still need to fix cache cleanup causing problems, see details at #28475 (comment).

Reviewing cheatsheet

Before merging the PR, comments starting with

  • ❌ ❓must be fixed
  • 🤔 💅 should be fixed
  • 💭 may be fixed
  • 🎉 celebrate happy things

@lptr lptr added the in:execution-engine incremental, up-to-date, overlapping outputs label Mar 19, 2024
@lptr lptr added this to the 8.7 RC4 milestone Mar 19, 2024
@lptr lptr self-assigned this Mar 19, 2024
@lptr lptr marked this pull request as ready for review March 19, 2024 14:32
@lptr lptr requested a review from a team as a code owner March 19, 2024 14:32
@lptr lptr requested review from a team as code owners March 19, 2024 15:50
@lptr lptr requested a review from big-guy March 19, 2024 15:50
@lptr
Copy link
Member Author

lptr commented Mar 19, 2024

@bot-gradle test QF please.

@bot-gradle
Copy link
Collaborator

I've triggered the following builds for you. Click here to see all build failures.

boolean moveSuccessful = workspace.withTemporaryWorkspace(temporaryWorkspace -> moveInconsistentImmutableWorkspaceToTemporaryLocation(immutableLocation, temporaryWorkspace, outputSnapshots));
if (moveSuccessful) {
return Optional.empty();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

💭 This is the heart of the change: if we find an inconsistent workspace, we don't throw, but instead try to move it out of the way. If we managed to move it out of the way, we act as if no existing workspace was found (Optional.empty()). If we fail to move, we fall back to trying to reuse what we found.

Copy link
Member

@asodja asodja left a comment

Choose a reason for hiding this comment

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

LGTM, but just wondering about what happens when move is not successful

"These workspace directories are not supposed to be modified once they are created. " +
"Deleting the directory in question can allow the content to be recreated.");
boolean moveSuccessful = workspace.withTemporaryWorkspace(temporaryWorkspace -> moveInconsistentImmutableWorkspaceToTemporaryLocation(immutableLocation, temporaryWorkspace, outputSnapshots));
if (moveSuccessful) {
Copy link
Member

Choose a reason for hiding this comment

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

❓ Is it ok we continue if move was not successful or should we fail in that case?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I added a clarifying comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thinking about this a bit more, I agree that this is weird. It's also a corner case, and I can't even imagine how it could possibly be triggered. Let's just fall back to failing the build in that case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Clarification: I can only imagine catastrophic ways this could fail, i.e. disk full, permissions on cache directory have changed etc. I can't come up with a scenario we would be expected to recover from.

@lptr lptr added this pull request to the merge queue Mar 19, 2024
@bot-gradle
Copy link
Collaborator

The merge queue build has started. Click here to see all failures if any.

@lptr lptr removed this pull request from the merge queue due to a manual request Mar 19, 2024
Copy link
Member

@asodja asodja left a comment

Choose a reason for hiding this comment

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

LGTM

@lptr lptr added this pull request to the merge queue Mar 19, 2024
@bot-gradle
Copy link
Collaborator

The merge queue build has started. Click here to see all failures if any.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in:execution-engine incremental, up-to-date, overlapping outputs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants