Changed uses of Apache Commons IO FileUtils.deleteDirectory to PathUtils.deleteDirectory #1658
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Symptom: Blob store state restore fails when verifying restored directory contents due to a mismatch between permissions of local vs remote files.
Cause: Apache Commons 2.11 (at least, more versions may be affected) FileUtils#deleteDirectory() has a bug where it changes the permissions of symlink/hardlink files to read-only after deletion. For more details, see https://issues.apache.org/jira/browse/IO-751. This means that TaskStorageCommitManager#deleteOldCheckpointDirs() causes the permissions for the original store files hard-linked from the checkpoint directory to be changed to read only. This causes the file to be considered different than the one already uploaded on next checkpoint and re-uploaded. Since restore recreates all files in rw mode, they fail post-restore verifications due to permissions mismatch.
Changes:
Since we cannot control which commons-io version the user application is using, this PR changes all uses of FileUtils#deleteDirectory to PathUtils#deleteDirectory() which is not affected. (according to the ticket above, and verifed with the failing test).
Unrelated cleanup: changed state backend integration tests to use a unique temp directory for each run.
Tests: Discovered with the BlobStoreStateBackendIntegrationTest added in PR #1657. Verified fix by re-running test with the bad apache-commons version.