scwhittle commented on code in PR #39473:
URL: https://github.com/apache/beam/pull/39473#discussion_r3795850099


##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/util/KeyGroupWorkQueue.java:
##########
@@ -67,9 +68,14 @@ static class Node {
     @Nullable Node prevKeyGroupNode;
     @Nullable Node nextKeyGroupNode;
 
+    private static boolean isMultiKeyBatchingDisabled(Runnable task) {
+      return (task instanceof QueuedWork)
+          && ((QueuedWork) task).getWork().isMultiKeyBatchingDisabled();
+    }
+
     Node(Runnable task) {
       this.task = task;
-      if (task instanceof QueuedWork) {
+      if (task instanceof QueuedWork && !isMultiKeyBatchingDisabled(task)) {

Review Comment:
   could just be 
   `if (!isMultiKeyBatchingDisabled(task)`



##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/work/processing/StreamingWorkScheduler.java:
##########
@@ -431,6 +427,8 @@ private void commitMultiKeyWorkBatch(
               .build());
     }
 
+    Windmill.MultiKeyWorkItemCommitRequest multiKeyCommitRequest = 
multiKeyBuilder.build();

Review Comment:
   does this possibly throw and thus is done earlier now? If so add a comment, 
if not maybe revert.



##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorkerTest.java:
##########
@@ -4884,6 +4890,395 @@ public void 
testSkipInputElementsWithDecodingExceptions() throws Exception {
         "12345", 
commit.getOutputMessages(0).getBundles(0).getMessages(0).getData().toStringUtf8());
   }
 
+  @Test
+  public void testMultiKeyCommit_batchCommitSizeExceededUnBatchSucceeds() 
throws Exception {
+    if (!streamingEngine) {
+      return;
+    }
+    KvCoder<String, String> kvCoder = KvCoder.of(StringUtf8Coder.of(), 
StringUtf8Coder.of());
+
+    List<ParallelInstruction> instructions =
+        Arrays.asList(
+            makeSourceInstruction(kvCoder),
+            makeDoFnInstruction(new FixedSizeCommitFn(500), 0, kvCoder),

Review Comment:
   maybe have a dofn that you can see that the work is re-executed?



##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorkerTest.java:
##########
@@ -4884,6 +4890,395 @@ public void 
testSkipInputElementsWithDecodingExceptions() throws Exception {
         "12345", 
commit.getOutputMessages(0).getBundles(0).getMessages(0).getData().toStringUtf8());
   }
 
+  @Test
+  public void testMultiKeyCommit_batchCommitSizeExceededUnBatchSucceeds() 
throws Exception {
+    if (!streamingEngine) {
+      return;
+    }
+    KvCoder<String, String> kvCoder = KvCoder.of(StringUtf8Coder.of(), 
StringUtf8Coder.of());
+
+    List<ParallelInstruction> instructions =
+        Arrays.asList(
+            makeSourceInstruction(kvCoder),
+            makeDoFnInstruction(new FixedSizeCommitFn(500), 0, kvCoder),
+            makeSinkInstruction(kvCoder, 1));
+
+    StreamingDataflowWorker worker =
+        makeWorker(
+            defaultWorkerParams(
+                    
"--experiments=unstable_enable_multi_key_bundle,windmill_max_key_group_batch_time_ms=5000",

Review Comment:
   larger timeout just so it isn't possibly flaky?



##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/windmill/work/processing/StreamingWorkScheduler.java:
##########
@@ -264,7 +264,7 @@ private void processWork(
       handleProcessWorkFailure(
           computationState, handle.getWorkBatch(), computationId, systemName, 
work, t);
     } finally {
-      List<Work> processedWorkBatch = workBatch != null ? workBatch : 
ImmutableList.of(work);
+      List<Work> processedWorkBatch = workBatch != null ? workBatch : 
handle.getWorkBatch();

Review Comment:
   is it always correct to use the handle batch? should we just use that and 
possibly remove from ExecuteWorkResult as well?



##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingModeExecutionContext.java:
##########


Review Comment:
   Maybe my terminology was confusing, but I was thinking of the case where 
each key is flushing to state that we might build up too large a commit to 
apply.  Then we have to retry all of the bundles locally without merging 
instead of just stopping earlier.  If we were counting the state bytes we could 
just stop before we built up such a large commit and wouldn't have to retry. 



##########
runners/google-cloud-dataflow-java/worker/src/test/java/org/apache/beam/runners/dataflow/worker/StreamingModeExecutionContextTest.java:
##########
@@ -900,4 +900,49 @@ public void testInternalsPoisonedAfterFlushState() throws 
Exception {
       assertThat(e.getMessage(), Matchers.containsString("poisoned"));
     }
   }
+
+  @Test
+  public void testAdvance_stopsWhenQueuedWorkBatchingDisabled() throws 
Exception {
+    DataflowWorkerHarnessOptions optionsMultiKey =
+        PipelineOptionsFactory.as(DataflowWorkerHarnessOptions.class);
+    optionsMultiKey
+        .as(ExperimentalOptions.class)
+        .setExperiments(Arrays.asList("unstable_enable_multi_key_bundle"));
+    StreamingModeExecutionContext context =
+        createExecutionContext(optionsMultiKey, globalConfigHandle);
+
+    BoundedQueueExecutor mockExecutor = mock(BoundedQueueExecutor.class);
+    BoundedQueueExecutorWorkHandle mockHandle = 
mock(BoundedQueueExecutorWorkHandle.class);
+    Windmill.Uint128Proto keyGroup =
+        Windmill.Uint128Proto.newBuilder().setHigh(1).setLow(2).build();
+
+    Work work1 =

Review Comment:
   I only see one work in this test so it doesn't seem like it is necessarily 
stopping because the batching is disabled.



-- 
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]

Reply via email to