elsa-core icon indicating copy to clipboard operation
elsa-core copied to clipboard

StartAt activity re fires on server restart

Open Suhail-Ismail opened this issue 1 year ago • 7 comments

I have created a visual workflow which uses StartAt as the first activity. This works as expected and executes the workflow at the specified time. But when we restart the server the same workflow is executed again.

The instant is defined like this "Instant.FromDateTimeUtc(new Date(2024, 4, 27, 11, 20, 27, 0))".

Suhail-Ismail avatar May 27 '24 12:05 Suhail-Ismail

To address the issue you're experiencing with the StartAt activity triggering the workflow again after a server restart, it's important to ensure that the workflow instance state is being persisted correctly and that the workflow is not set to start again upon application restart.

The StartAt activity should only trigger the workflow at the specified time, and if the workflow has already been triggered, it should not execute again unless it's a recurring trigger. Since you're using a specific instant in time, it should not re-trigger unless the workflow is designed to do so or there's an issue with the state persistence.

Here are a few steps you can take to troubleshoot the issue:

  1. Check the persistence provider: Ensure that your workflow state is being persisted to a database or other persistent storage. If you're using an in-memory provider, the state will be lost upon restart.

  2. Review the workflow definition: Make sure that the workflow is not designed to start again after a server restart. Look for any activities or configurations that might cause the workflow to re-trigger.

  3. Check the workflow instance status: After the workflow runs at the specified time, check the status of the workflow instance. It should be completed or halted, and not in a state that would cause it to run again after a restart.

  4. Review the logs: Check the application logs for any errors or messages that might indicate why the workflow is being executed again after a restart.

  5. Update to the latest version: If you're not using the latest version of Elsa, consider updating to the latest version as there might be bug fixes related to your issue.

If you continue to experience issues, you may want to reach out to the Elsa community or support channels for further assistance. Provide them with details about your workflow, the persistence configuration, and any relevant logs or error messages.

This comment was generated by Glime.

glime-ai[bot] avatar May 27 '24 12:05 glime-ai[bot]

@sfmskywalker can you help me to identiy why it might be triggering againt on restart.

Suhail-Ismail avatar May 28 '24 13:05 Suhail-Ismail

I will take a look soon. Question: are you using Quartz, Hangfire, or the default scheduling provider?

sfmskywalker avatar May 28 '24 15:05 sfmskywalker

I was able to reproduce this with the latest version on the main branch and created a PR containing a fix: #5454

sfmskywalker avatar May 28 '24 21:05 sfmskywalker

I will take a look soon. Question: are you using Quartz, Hangfire, or the default scheduling provider?

I am using Elsa 2.14 with quartz.

I have seen the PR for Elsa 3, but i cannot find same paths fro 2.14

Suhail-Ismail avatar May 29 '24 08:05 Suhail-Ismail

I see. Let me reopen this issue and update the label to match Elsa 2.

sfmskywalker avatar May 29 '24 09:05 sfmskywalker

I see. Let me reopen this issue and update the label to match Elsa 2.

Based on your fix for Elsa 3,

I added the below code in QuartzWorkflowDefinitionScheduler

if(startAt < Instant.FromDateTimeUtc(DateTime.UtcNow)) { return; }

I hope this is the correct place to do this

Suhail-Ismail avatar May 29 '24 10:05 Suhail-Ismail