Skip to content

Commit a676cd9

Browse files
authored
fix(clients): bump replaceAllObjects default maxRetries from 100 to 800 (#6580)
1 parent 83167f1 commit a676cd9

23 files changed

Lines changed: 69 additions & 25 deletions

File tree

clients/algoliasearch-client-csharp/algoliasearch/Utils/ChunkedHelperOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ namespace Algolia.Search.Utils;
55
/// </summary>
66
public class ChunkedHelperOptions
77
{
8+
/// <summary>
9+
/// Default maximum number of retries used by <c>ReplaceAllObjects</c>.
10+
/// </summary>
11+
public const int DefaultReplaceAllObjectsMaxRetries = 800;
12+
813
/// <summary>
914
/// Maximum number of retries when polling for task completion. Defaults to <see cref="RetryHelper.DefaultMaxRetries"/>.
1015
/// </summary>

clients/algoliasearch-client-csharp/algoliasearch/Utils/SearchClientExtensions.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,8 @@ public async Task<ReplaceAllObjectsResponse> ReplaceAllObjectsAsync<T>(
910910
)
911911
where T : class
912912
{
913-
var maxRetries = chunkedOptions?.MaxRetries ?? RetryHelper.DefaultMaxRetries;
913+
chunkedOptions ??= new ChunkedHelperOptions { MaxRetries = ChunkedHelperOptions.DefaultReplaceAllObjectsMaxRetries };
914+
var maxRetries = chunkedOptions.MaxRetries;
914915
if (objects == null)
915916
{
916917
throw new ArgumentNullException(nameof(objects));
@@ -1506,7 +1507,8 @@ public async Task<ReplaceAllObjectsWithTransformationResponse> ReplaceAllObjects
15061507
ChunkedHelperOptions chunkedOptions = null
15071508
)
15081509
{
1509-
var maxRetries = chunkedOptions?.MaxRetries ?? RetryHelper.DefaultMaxRetries;
1510+
chunkedOptions ??= new ChunkedHelperOptions { MaxRetries = ChunkedHelperOptions.DefaultReplaceAllObjectsMaxRetries };
1511+
var maxRetries = chunkedOptions.MaxRetries;
15101512
if (_ingestionTransporter == null)
15111513
{
15121514
throw new AlgoliaException(

clients/algoliasearch-client-dart/packages/client_core/lib/src/config/chunked_helper_options.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/// Default maximum number of retries for chunked helpers and wait operations.
22
const int defaultMaxRetries = 100;
33

4+
/// Default maximum number of retries used by `replaceAllObjects`.
5+
const int defaultReplaceAllObjectsMaxRetries = 800;
6+
47
/// Optional configuration for chunked helpers that batch records and poll for task completion.
58
///
69
/// Designed to grow over time; future shared helper config (e.g. timeout) can be

clients/algoliasearch-client-dart/packages/client_search/lib/src/extension/transformation.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ extension Transformation on SearchClient {
136136
}) async {
137137
if (ingestionTransporter == null) throw StateError(_notSetError);
138138

139-
final effectiveMaxRetries = chunkedOptions?.maxRetries ?? defaultMaxRetries;
139+
final effectiveChunkedOptions = chunkedOptions ??
140+
ChunkedHelperOptions(maxRetries: defaultReplaceAllObjectsMaxRetries);
141+
final effectiveMaxRetries = effectiveChunkedOptions.maxRetries;
140142
final effectiveScopes =
141143
scopes ?? [ScopeType.settings, ScopeType.rules, ScopeType.synonyms];
142144
final tmpIndex = '${indexName}_tmp_${Random().nextInt(900000) + 100000}';
@@ -158,7 +160,7 @@ extension Transformation on SearchClient {
158160
action: ingestion.Action.addObject,
159161
waitForTasks: true,
160162
batchSize: batchSize,
161-
chunkedOptions: chunkedOptions,
163+
chunkedOptions: effectiveChunkedOptions,
162164
referenceIndexName: indexName,
163165
requestOptions: requestOptions,
164166
);

clients/algoliasearch-client-java/algoliasearch/src/main/java/com/algolia/utils/ChunkedHelperOptions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
/** Optional configuration for chunked helpers that batch records and poll for task completion. */
44
public class ChunkedHelperOptions {
55

6+
/** Default maximum number of retries used by {@code replaceAllObjects}. */
7+
public static final int DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES = 800;
8+
69
private int maxRetries = TaskUtils.DEFAULT_MAX_RETRIES;
710

811
/**

clients/algoliasearch-client-javascript/packages/client-common/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ export const DEFAULT_WRITE_TIMEOUT_BROWSER = 30000;
55
export const DEFAULT_CONNECT_TIMEOUT_NODE = 2000;
66
export const DEFAULT_READ_TIMEOUT_NODE = 5000;
77
export const DEFAULT_WRITE_TIMEOUT_NODE = 30000;
8+
9+
export const DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES = 800;

clients/algoliasearch-client-kotlin/client/src/commonMain/kotlin/com/algolia/client/extensions/SearchClient.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import kotlinx.serialization.json.JsonObject
2727
/** The default maximum number of retries when polling for task completion. */
2828
public const val DEFAULT_MAX_RETRIES: Int = 100
2929

30+
/** The default maximum number of retries used by `replaceAllObjects`. */
31+
public const val DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES: Int = 800
32+
3033
private const val TRANSFORMATION_OPTIONS_REQUIRED =
3134
"`transformationOptions` must be installed on the client before calling this method. " +
3235
"Use `SearchClient.withTransformation(...)` or `searchClient.setTransformationOptions(...)`. " +
@@ -511,7 +514,7 @@ public suspend fun SearchClient.replaceAllObjects(
511514
batchSize: Int = 1000,
512515
scopes: List<ScopeType> = listOf(ScopeType.Settings, ScopeType.Rules, ScopeType.Synonyms),
513516
requestOptions: RequestOptions? = null,
514-
chunkedOptions: ChunkedHelperOptions = ChunkedHelperOptions(),
517+
chunkedOptions: ChunkedHelperOptions = ChunkedHelperOptions(maxRetries = DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES),
515518
): ReplaceAllObjectsResponse {
516519
val maxRetries = chunkedOptions.maxRetries
517520
val tmpIndexName = "${indexName}_tmp_${Random.nextInt(from = 0, until = 100)}"
@@ -868,7 +871,7 @@ public suspend fun SearchClient.replaceAllObjectsWithTransformation(
868871
batchSize: Int = 1000,
869872
scopes: List<ScopeType> = listOf(ScopeType.Settings, ScopeType.Rules, ScopeType.Synonyms),
870873
requestOptions: RequestOptions? = null,
871-
chunkedOptions: ChunkedHelperOptions = ChunkedHelperOptions(),
874+
chunkedOptions: ChunkedHelperOptions = ChunkedHelperOptions(maxRetries = DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES),
872875
): ReplaceAllObjectsWithTransformationResponse {
873876
val transporter = requireIngestionTransporter()
874877
val maxRetries = chunkedOptions.maxRetries

clients/algoliasearch-client-php/lib/Support/ChunkedHelperOptions.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
*/
1111
final class ChunkedHelperOptions
1212
{
13+
public const DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES = 800;
14+
1315
public function __construct(
1416
public ?int $maxRetries = null,
1517
) {}

clients/algoliasearch-client-python/algoliasearch/http/chunked_helper_options.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from dataclasses import dataclass
2+
from typing import ClassVar
23

34

45
@dataclass
@@ -7,4 +8,6 @@ class ChunkedHelperOptions:
78
Optional configuration for chunked helpers that batch records and poll for task completion.
89
"""
910

11+
DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES: ClassVar[int] = 800
12+
1013
max_retries: int = 100

clients/algoliasearch-client-ruby/lib/algolia/chunked_helper_options.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ module Algolia
22
# Optional configuration for chunked helpers that batch records and poll for task completion.
33
class ChunkedHelperOptions
44
DEFAULT_MAX_RETRIES = 100
5+
DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES = 800
56
attr_reader :max_retries
67

78
def initialize(max_retries: DEFAULT_MAX_RETRIES)
89
@max_retries = max_retries
910
end
1011

11-
def self.resolve(options)
12-
options || new
12+
def self.resolve(options, default_max_retries: DEFAULT_MAX_RETRIES)
13+
options || new(max_retries: default_max_retries)
1314
end
1415
end
1516
end

0 commit comments

Comments
 (0)