parveensania commented on code in PR #41825:
URL: https://github.com/apache/beam/pull/41825#discussion_r4761941077
##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/windmill/client/grpc/GrpcGetDataStreamTest.java:
##########
@@ -1138,6 +1141,123 @@ public <ReqT, RespT> ClientCall<ReqT, RespT>
interceptCall(
assertTrue(sendFuture.isCompletedExceptionally());
}
+ @Test
+ public void
testRequestKeyedData_sendFailureCleansPendingSoBatchWaitersRetry() throws
Exception {
+ AtomicBoolean failFirstMultiRequestBatchSend = new AtomicBoolean(true);
+ GrpcGetDataStream getDataStream =
+ (GrpcGetDataStream)
+ GrpcWindmillStreamFactory.of(TEST_JOB_HEADER)
+ .setSendKeyedGetDataRequests(false)
+ .build()
+ .createGetDataStream(
+ CloudWindmillServiceV1Alpha1Grpc.newStub(inProcessChannel)
+ .withInterceptors(
+ new ClientInterceptor() {
+ @Override
+ public <ReqT, RespT> ClientCall<ReqT, RespT>
interceptCall(
+ MethodDescriptor<ReqT, RespT>
methodDescriptor,
+ CallOptions callOptions,
+ Channel channel) {
+ return new
ForwardingClientCall.SimpleForwardingClientCall<
+ ReqT,
RespT>(channel.newCall(methodDescriptor, callOptions)) {
+ @Override
+ public void sendMessage(ReqT message) {
+ if (message instanceof
Windmill.StreamingGetDataRequest
+ && ((Windmill.StreamingGetDataRequest)
message)
+ .getRequestIdCount()
+ > 1
+ &&
failFirstMultiRequestBatchSend.compareAndSet(
+ true, false)) {
+ throw new RuntimeException("injected
send error");
+ }
+ super.sendMessage(message);
+ }
+ };
+ }
+ }));
+ getDataStream.start();
+ FakeWindmillGrpcService.GetDataStreamInfo streamInfo =
waitForConnectionAndConsumeHeader();
+
+ int numThreads = 8;
+ ExecutorService executor = Executors.newFixedThreadPool(numThreads);
+ CyclicBarrier barrier = new CyclicBarrier(numThreads);
+ try {
+ for (int attempt = 0; attempt < 5 &&
failFirstMultiRequestBatchSend.get(); attempt++) {
+ List<CompletableFuture<Windmill.KeyedGetDataResponse>> futures = new
ArrayList<>();
+ for (int i = 1; i <= numThreads; i++) {
+ long requestKey = i;
+ futures.add(
+ CompletableFuture.supplyAsync(
+ () -> {
+ try {
+ // Synchronize threads so they batch together within the
1ms batch window.
Review Comment:
Done. Removed the loop to attempt to trigger failure. It now runs a single
attempt and won't flake if the threads don't batch within 1ms (while still
failing without the fix whenever they do).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]