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

[8.11] Make S3 anti-contention delay configurable (#101245) #101251

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/101245.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 101245
summary: Make S3 anti-contention delay configurable
area: Snapshot/Restore
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,9 @@ void run(BytesReference expected, BytesReference updated, ActionListener<Optiona

if (uploadIndex > 0) {
threadPool.scheduleUnlessShuttingDown(
TimeValue.timeValueMillis(TimeValue.timeValueSeconds(uploadIndex).millis() + Randomness.get().nextInt(50)),
TimeValue.timeValueMillis(
uploadIndex * blobStore.getCompareAndExchangeAntiContentionDelay().millis() + Randomness.get().nextInt(50)
),
blobStore.getSnapshotExecutor(),
cancelConcurrentUpdates
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ public TimeValue getCompareAndExchangeTimeToLive() {
return service.compareAndExchangeTimeToLive;
}

public TimeValue getCompareAndExchangeAntiContentionDelay() {
return service.compareAndExchangeAntiContentionDelay;
}

// metrics collector that ignores null responses that we interpret as the request not reaching the S3 endpoint due to a network
// issue
private abstract static class IgnoreNoResponseMetricsCollector extends RequestMetricCollector {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ class S3Service implements Closeable {
Setting.Property.NodeScope
);

private static final Setting<TimeValue> REPOSITORY_S3_CAS_ANTI_CONTENTION_DELAY_SETTING = Setting.timeSetting(
"repository_s3.compare_and_exchange.anti_contention_delay",
TimeValue.timeValueSeconds(1),
TimeValue.timeValueMillis(1),
TimeValue.timeValueHours(24),
Setting.Property.NodeScope
);

private volatile Map<S3ClientSettings, AmazonS3Reference> clientsCache = emptyMap();

/**
Expand All @@ -79,6 +87,7 @@ class S3Service implements Closeable {
final CustomWebIdentityTokenCredentialsProvider webIdentityTokenCredentialsProvider;

final TimeValue compareAndExchangeTimeToLive;
final TimeValue compareAndExchangeAntiContentionDelay;

S3Service(Environment environment, Settings nodeSettings) {
webIdentityTokenCredentialsProvider = new CustomWebIdentityTokenCredentialsProvider(
Expand All @@ -88,6 +97,7 @@ class S3Service implements Closeable {
Clock.systemUTC()
);
compareAndExchangeTimeToLive = REPOSITORY_S3_CAS_TTL_SETTING.get(nodeSettings);
compareAndExchangeAntiContentionDelay = REPOSITORY_S3_CAS_ANTI_CONTENTION_DELAY_SETTING.get(nodeSettings);
}

/**
Expand Down