-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add exception mappers to convert storage failures to Iceberg REST c…
…lient exceptions * Attempt recovery from failed tasks if/when they are re-submitted after a configurable delay. * Add task deadlines (prevent indefinite retries) * Add AccessCheckHandler to ObjectStorageMock for simulating access failures in tests. Closes #8738
- Loading branch information
Showing
45 changed files
with
931 additions
and
637 deletions.
There are no files selected for viewing
84 changes: 0 additions & 84 deletions
84
...iles/api/src/main/java/org/projectnessie/catalog/files/api/BackendThrottledException.java
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
.../files/api/src/main/java/org/projectnessie/catalog/files/api/ObjectIOExceptionMapper.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,80 @@ | ||
/* | ||
* Copyright (C) 2024 Dremio | ||
* | ||
* 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 org.projectnessie.catalog.files.api; | ||
|
||
import java.time.Clock; | ||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.OptionalInt; | ||
import org.projectnessie.nessie.immutables.NessieImmutable; | ||
|
||
@NessieImmutable | ||
public abstract class ObjectIOExceptionMapper { | ||
|
||
protected abstract List<Analyzer> analyzers(); | ||
|
||
protected abstract Duration retryAfterThrottled(); | ||
|
||
protected abstract Duration retryAfterNetworkError(); | ||
|
||
protected abstract Duration reattemptAfterFetchError(); | ||
|
||
protected abstract Clock clock(); | ||
|
||
public static ImmutableObjectIOExceptionMapper.Builder builder() { | ||
return ImmutableObjectIOExceptionMapper.builder(); | ||
} | ||
|
||
public Optional<ObjectIOStatus> analyze(Throwable ex) { | ||
for (Throwable th = ex; th != null; th = th.getCause()) { | ||
for (Analyzer analyzer : analyzers()) { | ||
OptionalInt statusCode = analyzer.httpStatusCode(th); | ||
if (statusCode.isPresent()) { | ||
return Optional.of(toStatus(statusCode.getAsInt(), th)); | ||
} | ||
} | ||
} | ||
|
||
return Optional.empty(); | ||
} | ||
|
||
private Instant retryAfter(Duration delay) { | ||
return clock().instant().plus(delay); | ||
} | ||
|
||
private ObjectIOStatus toStatus(int httpStatus, Throwable th) { | ||
switch (httpStatus) { | ||
case 408: | ||
case 425: | ||
case 429: | ||
return ObjectIOStatus.of(httpStatus, true, retryAfter(retryAfterThrottled()), th); | ||
|
||
case 502: | ||
case 503: | ||
case 504: | ||
return ObjectIOStatus.of(httpStatus, true, retryAfter(retryAfterNetworkError()), th); | ||
|
||
default: | ||
return ObjectIOStatus.of(httpStatus, false, retryAfter(reattemptAfterFetchError()), th); | ||
} | ||
} | ||
|
||
public interface Analyzer { | ||
OptionalInt httpStatusCode(Throwable th); | ||
} | ||
} |
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
46 changes: 0 additions & 46 deletions
46
catalog/files/api/src/main/java/org/projectnessie/catalog/files/api/RetryableException.java
This file was deleted.
Oops, something went wrong.
129 changes: 0 additions & 129 deletions
129
.../api/src/test/java/org/projectnessie/catalog/files/api/TestBackendThrottledException.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.