You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "m-trieu (via GitHub)" <gi...@apache.org> on 2023/10/30 20:34:18 UTC

Re: [PR] check for cachetoken representing a retry before activating and completing work [beam]

m-trieu commented on code in PR #29082:
URL: https://github.com/apache/beam/pull/29082#discussion_r1376770666


##########
runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/streaming/ActiveWorkState.java:
##########
@@ -108,10 +130,26 @@ synchronized ActivateWorkResult activateWorkForKey(ShardedKey shardedKey, Work w
     }
 
     // Ensure we don't already have this work token queued.
-    for (Work queuedWork : workQueue) {
-      if (queuedWork.getWorkItem().getWorkToken() == work.getWorkItem().getWorkToken()) {
+    Iterator<Work> workQueueIterator = workQueue.iterator();
+    while (workQueueIterator.hasNext()) {
+      Work queuedWork = workQueueIterator.next();
+
+      // Work tokens and cache tokens are equal.
+      if (queuedWork.id().equals(work.id())) {
+        if (work.newerThan(queuedWork)) {

Review Comment:
   just to clarify:
   
   - `existingWorkToken` == `newWorkToken` && `existingCacheToken` == `newCacheToken`: return DUPLICATE
   - `existingWorkToken` > `newWorkToken` && `existingCacheToken` == `cacheToken2`: ignore
   - `existingWorkToken` < `newWorkToken` && `existingCacheToken` == `cacheToken2`: return QUEUED (queue newWorkToken, removeExistingWorkToken if it is not active)
   - `existingWorkToken` == `newWorkToken` && `existingCacheToken` != `newCacheToken`: return QUEUED (queue newWorkToken, removeExistingWorkToken if it is not active)
   
   is this the behavior we want? If it is equal cache tokens, but different work tokens what does that mean?  Same worker with different work?
   
   
   



-- 
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: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org