-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suppress last-ditch download exceptions w/cleanup
Create an encapsulating DownloadException to represent the aggregate exception set of an ActionResult download. IOExceptions will be retained through exception suppression, and the outer exception has a property to indicate if it only represents a sequence of CacheNotFoundExceptions. InterruptedExceptions interception is improved to cancel pending work and wrap, through suppression, any DownloadException that also occurred during the download. InterruptedException being thrown on the download control thread, it does not require suppression of further interrupts, and can represent an outer download exception. Thread interrupt status is suppressed for cancellations, and conveyed on throw. These exception wrapping efforts allow non-asynchronous frame representation in stack traces, and much clearer identification of sources within remote strategy execution which produce failures based on remote errors. Any DownloadException in the last-ditch output download under handleError in RemoteSpawnRunner is added as suppressed to the initiating exception. Other exceptions (likely local IO) present clear immediate traces and do not require specialized treatment. Closes #10029. PiperOrigin-RevId: 306619678
- Loading branch information
Showing
6 changed files
with
171 additions
and
126 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/main/java/com/google/devtools/build/lib/remote/BulkTransferException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2020 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package com.google.devtools.build.lib.remote; | ||
|
||
import com.google.devtools.build.lib.remote.common.CacheNotFoundException; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Exception which represents a collection of IOExceptions for the purpose of distinguishing remote | ||
* communication exceptions from those which occur on filesystems locally. This exception serves as | ||
* a trace point for the actual transfer, so that the intended operation can be observed in a stack, | ||
* with all constituent exceptions available for observation. | ||
*/ | ||
class BulkTransferException extends IOException { | ||
// true since no empty BulkTransferException is ever thrown | ||
private boolean allCacheNotFoundException = true; | ||
|
||
BulkTransferException() {} | ||
|
||
BulkTransferException(IOException e) { | ||
add(e); | ||
} | ||
|
||
/** | ||
* Add an IOException to the suppressed list. | ||
* | ||
* <p>The Java standard addSuppressed is final and this method stands in its place to selectively | ||
* filter and record whether all suppressed exceptions are CacheNotFoundExceptions | ||
*/ | ||
void add(IOException e) { | ||
allCacheNotFoundException &= e instanceof CacheNotFoundException; | ||
super.addSuppressed(e); | ||
} | ||
|
||
boolean onlyCausedByCacheNotFoundException() { | ||
return allCacheNotFoundException; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.