Skip to content

Commit b067a11

Browse files
committed
Throw an exception when Reindex() produces just enough documents for … (#2781)
* Throw an exception when Reindex() produces just enough documents for a single bulk but leaves no slots to call MoveNext() which would free up an awaiting task. fixes #2771 * improved exception message when backpressure does not leave room for the producer to call MoveNext()
1 parent 154a9a5 commit b067a11

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/Nest/CommonAbstractions/Reactive/CoordinatedRequestObserverBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Nest
44
{
55
internal static class CoordinatedRequestDefaults
66
{
7-
public static int BulkAllMaxDegreeOfParallelismDefault = 20;
7+
public static int BulkAllMaxDegreeOfParallelismDefault = 4;
88
public static TimeSpan BulkAllBackOffTimeDefault = TimeSpan.FromMinutes(1);
99
public static int BulkAllBackOffRetriesDefault = 0;
1010
public static int BulkAllSizeDefault = 1000;

src/Nest/Document/Multiple/Reindex/ReindexObservable.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ private ProducerConsumerBackPressure CreateBackPressure(IBulkAllRequest<IHitMeta
131131
+ $" which is smaller then the bulkSize:{bulkSize}."
132132
);
133133

134+
var funnelExact = producerBandwidth == bulkSize;
135+
if (funnelExact)
136+
throw new Exception("The back pressure settings are too conservative. They provide enough documents for a single bulk but not enough room to advance "
137+
+ $"searchSize:{searchSize} * maxConcurrency:{maxConcurrency} * backPressureFactor:{backPressureFactor} = {producerBandwidth}"
138+
+ $" which is exactly the bulkSize:{bulkSize}. Increase the BulkAll max concurrency or the backPressureFactor"
139+
);
140+
134141
var backPressure = new ProducerConsumerBackPressure(backPressureFactor, maxConcurrency);
135142
return backPressure;
136143
}
@@ -235,4 +242,4 @@ public void Dispose()
235242
this._compositeCancelTokenSource?.Cancel();
236243
}
237244
}
238-
}
245+
}

0 commit comments

Comments
 (0)