Problem/Motivation

Processes of the following Template will hang on "AndTask wait" forever.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork maestro-3552133

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

luenemann created an issue. See original summary.

luenemann’s picture

I have a patch to fix this.
It is an issue with setting the regeneration flag on to many maestro_queue entities. In this case "Start"

I'd like to provide an automated test for this scenario.

_randy’s picture

Ok while the engine shouldn't have an issue with this arrangement, I don't understand the purpose of the AND.

I think that validation should be expanded to include detection of AND pointing back to start. In fact, I think that no task should point back to start in general.

luenemann’s picture

Thank you for acknowledging that the workflow should have no issues.

This is a minimal workflow to demonstrate the issue.
I've tried to remove all unnecessary tasks. "dummy task1" is only there to make the pointers / arrows visible.
There can be more tasks anywhere and the problem persists.
The purpose of the AndTask is to wait for two parallel branches to finish.

The "AndTask wait" is not pointing back to start.

I've attached the template config and a patch to make the workflow run without issues.

There are some entity queries which can be optimized too. Should that be handled in this ore in a separate issue?

_randy’s picture

OK, I'll give the engine a test with the scenario you provided. Curious to know why you changed the getValue to getString?

We target the AND task specifically in the engine for this exact reason -- The AND execution does indeed check for <> TASK_ARCHIVE_REGEN, so I have to be very certain that including the <> 2 condition in the engine is the right thing to do here.

(For entity queries, that should be a separate issue, however, some queries were expanded on purpose for clarity in debugging)

_randy’s picture

In testing this patch, I see a new issue happening where for some reason the IF task does not work properly -- it does not follow the TRUE path and as a result, the dummyTaskToFix... task is always generated on first pass through.

I agree on changing the getValue to getString. But the bigger issue is that the logic is broken with this approach.

I have to run it through some more of my local engine tests and come up with a different solution.

  • _randy committed 8b401944 on 4.x
    [#3552133] feat: AndTask after loop never succeeds
    
_randy’s picture

Assigned: Unassigned » _randy
Status: Active » Needs review

I've made a few small alterations to the logic. I've committed what I think is an update to the engine that will support the scenario you've noted and should keep the rest of the logic intact.

luenemann’s picture

Your fix works as well. But i think it is confusing, especially with the comment above: "Race condition? ... Leave for now."

I did some git archaeology. The code appeared first in 2017. It looked like this:

          $query = \Drupal::service('entity.query')
            ->get('maestro_queue')
            ->condition('archived', '1')  //race condition?  what if its complete and not archived, yet a loopback happens?  Leave for now
            ->condition('status', '0')
            ->condition('process_id', $processID)
            ->condition('task_class_name', 'MaestroAnd');  //task is an AND
          $andIDs = $query->execute();  //going to use these IDs to determine who points to them

status == active and archived == archived is a condition which never matches. I interpret the comment as "This isn't working, somehow. So make it make it do nothing.
The code below was dead, effectively.

I have an idea what the problem was.

You observed the following:

In testing this patch, I see a new issue happening where for some reason the IF task does not work properly -- it does not follow the TRUE path and as a result, the dummyTaskToFix... task is always generated on first pass through.

That is an effect of reusing the $taskID variable in the loop over $pointers. $taskID is used to generate the task:

  $queueID = $this->createProductionTask($taskID, $template, $processID);

This is fixed with your latest commit.

luenemann’s picture

I propose to remove the archive condition and the comment above.

I've created a merge request with my proposal and 2 test cases.

There is still an issue with the current logic. Because there needs to be a task between the IfTask and the AndTask. This is a limitation of the current data model. I think transitions between the tasks need to be recorded as well to resolve that problem. But that is for another issue.

The merge request has 2 templates. One with and one without a workaround task.

The tests are working but there is definitively room for improvement.

Please review.

_randy’s picture

Thanks, give me a bit of time to look at the MR and I'll get back to you.

_randy’s picture

I'll let you update the MR as I think https://www.drupal.org/project/maestro/issues/3552704#comment-16307445 will cover the AND issue you noted. This was in the wings for some time and now is a good time as any to update the AND logic and IF false branch status.

  • _randy committed f722a31c on 4.x
    [#3552133] feat: AndTask after loop never succeeds. Removed Race...
luenemann’s picture

Status: Needs review » Reviewed & tested by the community

I've updated the tests.

Fixed a bug in commit #3552704-2: Update AND task for false branch detection

_randy’s picture

Thanks for the MR! Let's update the test flow names and the need for the post-IF task to remove the word "workaround" and solidify those tests.

luenemann’s picture

Status: Reviewed & tested by the community » Needs work

NR for [3552133-17]

luenemann’s picture

Status: Needs work » Needs review

Workaround test removed.

luenemann’s picture

Version: 4.2.3 » 4.x-dev

  • _randy committed 2e887408 on 4.x authored by luenemann
    [#3552133] feat: AndTask after loop never succeeds - remove workaround...
_randy’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.