Skip to content

Commit ec7b652

Browse files
authored
[Streaming Indexing] Fix intermittent 'The bulk request must be terminated by a newline [\n]' failures (#16337)
* [Streaming Indexing] Fix intermittent 'The bulk request must be terminated by a newline [\n]' failures Signed-off-by: Andriy Redko <[email protected]> * Address code review comments Signed-off-by: Andriy Redko <[email protected]> --------- Signed-off-by: Andriy Redko <[email protected]>
1 parent 6594516 commit ec7b652

File tree

12 files changed

+34
-7
lines changed

12 files changed

+34
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8282
- Fix warnings from SLF4J on startup when repository-s3 is installed ([#16194](https://github.com/opensearch-project/OpenSearch/pull/16194))
8383
- Fix protobuf-java leak through client library dependencies ([#16254](https://github.com/opensearch-project/OpenSearch/pull/16254))
8484
- Fix multi-search with template doesn't return status code ([#16265](https://github.com/opensearch-project/OpenSearch/pull/16265))
85+
- [Streaming Indexing] Fix intermittent 'The bulk request must be terminated by a newline [\n]' failures [#16337](https://github.com/opensearch-project/OpenSearch/pull/16337))
8586
- Fix wrong default value when setting `index.number_of_routing_shards` to null on index creation ([#16331](https://github.com/opensearch-project/OpenSearch/pull/16331))
8687
- Fix disk usage exceeds threshold cluster can't spin up issue ([#15258](https://github.com/opensearch-project/OpenSearch/pull/15258)))
8788

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ netty = 4.1.114.Final
3434
joda = 2.12.7
3535

3636
# project reactor
37-
reactor_netty = 1.1.22
37+
reactor_netty = 1.1.23
3838
reactor = 3.5.20
3939

4040
# client dependencies

plugins/repository-azure/licenses/reactor-netty-core-1.1.22.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a7059b0c18ab7aa0fa9e08b48cb6a20b15c11478

plugins/repository-azure/licenses/reactor-netty-http-1.1.22.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
94b294fa90aee2e88ad4337251e278aaac21362c

plugins/transport-reactor-netty4/licenses/reactor-netty-core-1.1.22.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a7059b0c18ab7aa0fa9e08b48cb6a20b15c11478

plugins/transport-reactor-netty4/licenses/reactor-netty-http-1.1.22.jar.sha1

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
94b294fa90aee2e88ad4337251e278aaac21362c

plugins/transport-reactor-netty4/src/javaRestTest/java/org/opensearch/rest/ReactorNetty4StreamingIT.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,11 +304,36 @@ public void testStreamingLargeDocument() throws IOException {
304304
String.format(
305305
Locale.getDefault(),
306306
"{ \"index\": { \"_index\": \"test-streaming\", \"_id\": \"1\" } }\n{ \"name\": \"%s\" }\n",
307-
randomAlphaOfLength(5000)
307+
randomAlphaOfLength(7000)
308+
)
309+
);
310+
311+
final StreamingRequest<ByteBuffer> streamingRequest = new StreamingRequest<>(
312+
"POST",
313+
"/_bulk/stream",
314+
Flux.fromStream(stream).map(s -> ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8)))
315+
);
316+
317+
final StreamingResponse<ByteBuffer> streamingResponse = client().streamRequest(streamingRequest);
318+
319+
StepVerifier.create(Flux.from(streamingResponse.getBody()).map(b -> new String(b.array(), StandardCharsets.UTF_8)))
320+
.expectNextMatches(s -> s.contains("\"result\":\"created\"") && s.contains("\"_id\":\"1\""))
321+
.expectComplete()
322+
.verify();
323+
324+
assertThat(streamingResponse.getStatusLine().getStatusCode(), equalTo(200));
325+
assertThat(streamingResponse.getWarnings(), empty());
326+
}
327+
328+
public void testStreamingLargeDocumentThatExceedsChunkSize() throws IOException {
329+
final Stream<String> stream = Stream.of(
330+
String.format(
331+
Locale.getDefault(),
332+
"{ \"index\": { \"_index\": \"test-streaming\", \"_id\": \"1\" } }\n{ \"name\": \"%s\" }\n",
333+
randomAlphaOfLength(9000) /* the default chunk size limit is set 8k */
308334
)
309335
);
310336

311-
final Duration delay = Duration.ofMillis(1);
312337
final StreamingRequest<ByteBuffer> streamingRequest = new StreamingRequest<>(
313338
"POST",
314339
"/_bulk/stream",

plugins/transport-reactor-netty4/src/main/java/org/opensearch/http/reactor/netty4/ReactorNetty4HttpServerTransport.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ protected HttpServerChannel bind(InetSocketAddress socketAddress) throws Excepti
230230
spec -> spec.maxChunkSize(maxChunkSize.bytesAsInt())
231231
.maxHeaderSize(maxHeaderSize.bytesAsInt())
232232
.maxInitialLineLength(maxInitialLineLength.bytesAsInt())
233+
.allowPartialChunks(false)
233234
)
234235
.handle((req, res) -> incomingRequest(req, res))
235236
);

0 commit comments

Comments
 (0)