You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "shootsoft (via GitHub)" <gi...@apache.org> on 2024/03/07 04:23:59 UTC

[I] Parallel state in Serverless workflow is executed in single thread? [incubator-kie-kogito-runtimes]

shootsoft opened a new issue, #3429:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/issues/3429

   ### Describe the bug
   
   Hi all
   
   I'm trying to integration Serverless workflow with my application, however, I found that Parallel state is executed in single thread, which multiple branches are executed one by one.
   
   
   
   ### Expected behavior
   
   In the example, I have two branches, each branch calls a java function which will sleep for 3 seconds.
   
   I'm expecting the function to be called in different threads so that two output should be showed with the same/very close timestamp.
   
   ```
   Thread [1]
   Timestamp [2024-03-07T04:15:29.476956Z] Thread [x] Hello branch1
   Timestamp [2024-03-07T04:15:29.492269Z] Thread [y] Hello branch2
   {workflowdata={}}
   ```
   
   ### Actual behavior
   
   ```
   Thread [1]
   Timestamp [2024-03-07T04:15:29.476956Z] Thread [1] Hello branch1
   Timestamp [2024-03-07T04:15:32.492269Z] Thread [1] Hello branch2
   {workflowdata={}}
   ```
   
   ### How to Reproduce?
   
   `bug/Hello.java`
   
   ```java
   public class Hello {
       public static void say(final String name) throws Exception {
           Thread.sleep(3000);
           System.out.printf(
                   "Timestamp [%s] Thread [%s] Hello %s%n",
                   Instant.now().toString(), Thread.currentThread().getId(), name);
       }
   
       @Test
       public void testParallel() throws IOException {
           System.out.printf("Thread [%s]%n", Thread.currentThread().getId());
           Reader reader = new InputStreamReader(
                   Thread.currentThread().getContextClassLoader().getResourceAsStream("workflow/parallel_hello.sw.json"));
           final Workflow workflow = getWorkflow(reader, WorkflowFormat.JSON);
   
           try (StaticWorkflowApplication application = StaticWorkflowApplication.create()) {
               final JsonNodeModel model = application.execute(workflow, emptyMap());
               System.out.println(model.toMap());
           }
       }
   }
   ```
   
   `resources/workflow/parallel_hello.sw.json`
   
   ```javascript
   {
     "id": "parallel_hello",
     "version": "1.0",
     "name": "parallel_hello",
     "start": "prepare",
     "functions": [
       {
         "name": "hello",
         "type": "custom",
         "operation": "service:Java:bug.Hello::say"
       }
     ],
     "states": [
       {
         "name": "prepare",
         "type": "parallel",
         "branches": [
           {
             "name": "branch1",
             "actions": [
               {
                 "functionRef": {
                   "refName": "hello",
                   "arguments": {
                     "name": "branch1"
                   }
                 }
               }
             ]
           },
           {
             "name": "branch2",
             "actions": [
               {
                 "functionRef": {
                   "refName": "hello",
                   "arguments": {
                     "name": "branch2"
                   }
                 }
               }
             ]
           }
         ],
         "numCompleted": "2",
         "end": true
       }
     ]
   }
   ```
   
   ### Output of `uname -a` or `ver`
   
   _No response_
   
   ### Output of `java -version`
   
   _No response_
   
   ### GraalVM version (if different from Java)
   
   _No response_
   
   ### Kogito version or git rev (or at least Quarkus version if you are using Kogito via Quarkus platform BOM)
   
   _No response_
   
   ### Build tool (ie. output of `mvnw --version` or `gradlew --version`)
   
   _No response_
   
   ### Additional information
   
   _No response_


-- 
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: commits-unsubscribe@kie.apache.org.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] Parallel state in Serverless workflow is executed in single thread? [incubator-kie-kogito-runtimes]

Posted by "fjtirado (via GitHub)" <gi...@apache.org>.
fjtirado commented on issue #3429:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/issues/3429#issuecomment-1985422131

   Parallel states, by desing of the underlyng engine, which is single thread,are not executed concurrently. Parallel means there is not logical dependency between the branches, so it does not matter in which order they are executed


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] Parallel state in Serverless workflow is executed in single thread? [incubator-kie-kogito-runtimes]

Posted by "fjtirado (via GitHub)" <gi...@apache.org>.
fjtirado closed issue #3429: Parallel state in Serverless workflow is executed in single thread? 
URL: https://github.com/apache/incubator-kie-kogito-runtimes/issues/3429


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [I] Parallel state in Serverless workflow is executed in single thread? [incubator-kie-kogito-runtimes]

Posted by "shootsoft (via GitHub)" <gi...@apache.org>.
shootsoft commented on issue #3429:
URL: https://github.com/apache/incubator-kie-kogito-runtimes/issues/3429#issuecomment-1982346276

   Also tried async call
   
   ```javascript
     {
             "name": "branch2",
             "actions": [
               {
                 "functionRef": {
                   "refName": "hello",
                   "invoke": "async",
                   "arguments": {
                     "name": "branch2"
                   }
                 }
               }
             ]
           }
   ```
   
   Seems to be the same.


-- 
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: commits-unsubscribe@kie.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org