Skip to content

Commit

Permalink
review: move throttled-retry-after to CatalogConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
dimas-b committed Jul 18, 2024
1 parent be12964 commit 2b4e476
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ as necessary. Empty sections will not end in the release notes.

- The `throttled-retry-after` advanced configuration property was renamed from
`nessie.catalog.service.s3.throttled-retry-after` to
`nessie.catalog.service.error-handling.throttled-retry-after`. The old property name is ignored.
`nessie.catalog.error-handling.throttled-retry-after`. The old property name is ignored.

### New Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static org.projectnessie.catalog.service.config.CatalogConfig.removeTrailingSlash;

import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import org.projectnessie.nessie.docgen.annotations.ConfigDocs.ConfigItem;
Expand Down Expand Up @@ -57,6 +58,16 @@ public interface CatalogConfig {
@ConfigItem(section = "warehouseDefaults")
Map<String, String> icebergConfigOverrides();

/**
* Advanced property. The time interval after which a request is retried when storage I/O responds
* with some "retry later" response.
*/
@ConfigPropertyName("throttled-retry-after")
@ConfigItem(section = "error-handling")
default Duration retryAfterThrottled() {
return Duration.ofSeconds(10);
}

/**
* Returns the given {@code warehouse} if not-empty or the {@link #defaultWarehouse() default
* warehouse}. Throws an {@link IllegalStateException} if neither is given/present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import java.util.function.Supplier;
import java.util.stream.Stream;
import org.projectnessie.api.v2.params.ParsedReference;
import org.projectnessie.catalog.files.api.BackendExceptionMapper;
import org.projectnessie.catalog.files.api.ObjectIO;
import org.projectnessie.catalog.formats.iceberg.IcebergSpec;
import org.projectnessie.catalog.formats.iceberg.meta.IcebergJson;
Expand Down Expand Up @@ -117,15 +118,20 @@ public class CatalogServiceImpl implements CatalogService {
@Inject NessieApiV2 nessieApi;
@Inject Persist persist;
@Inject TasksService tasksService;
@Inject EntitySnapshotTaskBehavior snapshotTaskBehavior;
@Inject BackendExceptionMapper backendExceptionMapper;
@Inject CatalogConfig catalogConfig;

@Inject
@Named("import-jobs")
Executor executor;

private IcebergStuff icebergStuff() {
return new IcebergStuff(objectIO, persist, tasksService, snapshotTaskBehavior, executor);
return new IcebergStuff(
objectIO,
persist,
tasksService,
new EntitySnapshotTaskBehavior(backendExceptionMapper, catalogConfig.retryAfterThrottled()),
executor);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@
import org.projectnessie.nessie.tasks.api.TaskState;
import org.projectnessie.versioned.storage.common.persist.ObjType;

public final class EntitySnapshotTaskBehavior
final class EntitySnapshotTaskBehavior
implements TaskBehavior<EntitySnapshotObj, EntitySnapshotObj.Builder> {
private final BackendExceptionMapper exceptionMapper;
private final Duration retryAfterThrottled;

public EntitySnapshotTaskBehavior(
BackendExceptionMapper exceptionMapper, Duration retryAfterThrottled) {
EntitySnapshotTaskBehavior(BackendExceptionMapper exceptionMapper, Duration retryAfterThrottled) {
this.exceptionMapper = exceptionMapper;
this.retryAfterThrottled = retryAfterThrottled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import static org.projectnessie.services.authz.AbstractBatchAccessChecker.NOOP_ACCESS_CHECKER;

import java.time.Clock;
import java.time.Duration;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -201,9 +200,7 @@ private void setupCatalogService() {
catalogService.executor = executor;
catalogService.nessieApi = api;

BackendExceptionMapper exceptionMapper = BackendExceptionMapper.builder().build();
catalogService.snapshotTaskBehavior =
new EntitySnapshotTaskBehavior(exceptionMapper, Duration.ofMillis(1));
catalogService.backendExceptionMapper = BackendExceptionMapper.builder().build();
}

private void setupObjectIO() {
Expand Down
2 changes: 1 addition & 1 deletion helm/nessie/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ data:
{{- if .Values.catalog.enabled -}}
{{- list .Values.catalog.iceberg $map | include "nessie.applyCatalogIcebergOptions" -}}
{{- if .Values.catalog.storage.retryAfter -}}
{{- $_ = set $map "nessie.catalog.service.error-handling.throttled-retry-after" .Values.catalog.storage.retryAfter -}}
{{- $_ = set $map "nessie.catalog.error-handling.throttled-retry-after" .Values.catalog.storage.retryAfter -}}
{{- end -}}
{{- list .Values.catalog.storage.s3 "nessie.catalog.service.s3." $map | include "nessie.applyCatalogStorageS3RootOptions" }}
{{- list .Values.catalog.storage.s3.defaultOptions "nessie.catalog.service.s3.default-options." $map | include "nessie.applyCatalogStorageS3BucketOptions" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@

@ConfigMapping(prefix = "nessie.catalog.service")
public interface CatalogServiceConfig {
/**
* Advanced property. The time interval after which a request is retried when storage I/O responds
* with some "retry later" response.
*/
@WithName("error-handling.throttled-retry-after")
@WithDefault("PT10S")
Duration retryAfterThrottled();

/** Advanced property, defines the maximum number of concurrent imports from object stores. */
@WithName("imports.max-concurrent")
@WithDefault("32")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
import io.smallrye.config.WithName;
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import org.projectnessie.catalog.service.config.CatalogConfig;
Expand Down Expand Up @@ -47,4 +48,9 @@ public interface QuarkusCatalogConfig extends CatalogConfig {
@Override
@WithName("iceberg-config-overrides")
Map<String, String> icebergConfigOverrides();

@Override
@WithName("error-handling.throttled-retry-after")
@WithDefault("PT10S")
Duration retryAfterThrottled();
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import org.projectnessie.catalog.files.s3.S3Signer;
import org.projectnessie.catalog.secrets.SecretsProvider;
import org.projectnessie.catalog.service.config.CatalogConfig;
import org.projectnessie.catalog.service.impl.EntitySnapshotTaskBehavior;
import org.projectnessie.catalog.service.impl.IcebergExceptionMapper;
import org.projectnessie.catalog.service.impl.IllegalArgumentExceptionMapper;
import org.projectnessie.catalog.service.impl.NessieExceptionMapper;
Expand Down Expand Up @@ -216,13 +215,6 @@ public RequestSigner signer(
return new S3Signer(s3config, secretsProvider, s3sessions);
}

@Produces
@Singleton
public EntitySnapshotTaskBehavior entitySnapshotTaskBehavior(
CatalogServiceConfig config, BackendExceptionMapper mapper) {
return new EntitySnapshotTaskBehavior(mapper, config.retryAfterThrottled());
}

@Produces
@Singleton
public BackendExceptionMapper backendExceptionMapper() {
Expand Down
6 changes: 6 additions & 0 deletions site/in-dev/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ Related Quarkus settings:

#### Advanced catalog settings

##### Error Handling

{% include './generated-docs/smallrye-nessie_catalog_error_handling.md' %}

##### Performance Tuning

{% include './generated-docs/smallrye-nessie_catalog_service.md' %}

### Version Store Settings
Expand Down

0 comments on commit 2b4e476

Please sign in to comment.