Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.3.0-rc-3 => Elsa.Retention.Options: Missing SweepInterval #6194

Closed
r-kernberger opened this issue Dec 9, 2024 · 8 comments
Closed

3.3.0-rc-3 => Elsa.Retention.Options: Missing SweepInterval #6194

r-kernberger opened this issue Dec 9, 2024 · 8 comments
Labels
bug Something isn't working
Milestone

Comments

@r-kernberger
Copy link

In the class Elsa.Retention.Options.CleanupOptions of package Retention, there is missing an important setting, which has been available in prior versions of the retention module

=> SweepInterval

With this settting it has been possible to define how often the Retention Job is running (every x days, hours, minutes).

Now with this settings missing, there is the default value of every 4 hours. Which is especially for development / testing not good.

Will this setting be available in v3.3? Has this been removed on purpose?

@r-kernberger r-kernberger added the bug Something isn't working label Dec 9, 2024
@jayachandra21
Copy link

Hello @r-kernberger, I have observed the same at the Elsa 3.3.0 RC3.
Also I have configured the Retention module with following and I have observed that instances are not deleted.
Even if, Sweep Interval is 4 hours, I could still see the instances are which older then the 4 hours.

elsa.UseRetention(retention =>
  {
      retention.ConfigureCleanupOptions = options =>
      {
          //options.SweepInterval = TimeSpan.FromHours(4);
          options.PageSize = 25;
      };
  });

@r-kernberger
Copy link
Author

r-kernberger commented Dec 10, 2024

Did you define a delete policy like this:

retention.AddDeletePolicy("Delete Workflow Instances", _ => new DeleteFilter());

The DeleteFilter could look like this

public class DeleteFilter : RetentionWorkflowInstanceFilter
{
    //Finished Workflows
    public DeleteFilter()
    {
        WorkflowStatus = Elsa.Workflows.WorkflowStatus.Finished;
    }
}

Update:
I double checked it. My Instances have not been deleted despite defining a delete policy like above. Not even after 4 hours waiting.

@jayachandra21
Copy link

jayachandra21 commented Dec 10, 2024

Did you define a delete policy like this:

retention.AddDeletePolicy("Delete Workflow Instances", _ => new DeleteFilter());

The DeleteFilter could look like this

public class DeleteFilter : RetentionWorkflowInstanceFilter
{
    //Finished Workflows
    public DeleteFilter()
    {
        WorkflowStatus = Elsa.Workflows.WorkflowStatus.Finished;
    }
}

Update: I double checked it. My Instances have not been deleted despite defining a delete policy like above. Not even after 4 hours waiting.

Yes, it is the same from myside too. The following i have configured.
elsa.UseRetention(retention =>
{
retention.ConfigureCleanupOptions = options =>
{
options.PageSize = 25;
};

 retention.AddDeletePolicy("Delete completed workflows", sp =>
 {
     RetentionWorkflowInstanceFilter filter = new()
     {
         WorkflowStatus = WorkflowStatus.Finished
     };
     return filter;
 });

});

@sfmskywalker sfmskywalker moved this to Triage in ELSA 3 Dec 12, 2024
@sfmskywalker sfmskywalker added this to the Elsa 3.3 milestone Dec 12, 2024
@Sverre-W
Copy link
Contributor

Sverre-W commented Dec 13, 2024

I've made a PR: #6208 to add the SweepInterval. Not sure why it's not deleting, I will try to replicate and fix it over the weekend.

@Sverre-W
Copy link
Contributor

Sverre-W commented Dec 14, 2024

I've tested with a simple writeline workflow but seems to work as expected.

My setup:

  elsa.UseRetention(r =>
            {
                r.SweepInterval = TimeSpan.FromSeconds(30);
                r.AddDeletePolicy("Delete all finished workflows", _ => new RetentionWorkflowInstanceFilter()
                {
                    WorkflowStatus = WorkflowStatus.Finished
                });
            });

Output:

info: Elsa.Retention.Jobs.CleanupJob[0]
      Cleaned up 1 workflow instances through Delete all finished workflows
Hello world
Hello world
Hello world
info: Elsa.Retention.Jobs.CleanupJob[0]
      Cleaned up 3 workflow instances through Delete all finished workflows

Note: I did notice the minum sweep interval is 1 minute, settings 30 seconds will still result in one sweep per minute.

@sfmskywalker
Copy link
Member

Done via #6211
Thanks @Sverre-W !

@github-project-automation github-project-automation bot moved this from Triage to Done in ELSA 3 Dec 14, 2024
@jayachandra21
Copy link

Hello @Sverre-W ,

Thank you very much!
I have configured the retention module with Elsa 3.0 RC4 as below.

elsa.UseRetention(r =>
            {
                r.SweepInterval = TimeSpan.FromMinutes(10);
                r.AddDeletePolicy("Delete all finished workflows", _ => new RetentionWorkflowInstanceFilter()
                {
                    WorkflowStatus = WorkflowStatus.Finished
                });
            });

I think the Sweep Interval is considering the minute to delete the finished instances but not considered the configured as above.

Step1: Local time is 6:20 - I have 9 instances with finished state
image

Step2 : At 6:24 - Deleted the all above instances.
image

Is it something missing in the configuration to work as expected?

@jayachandra21
Copy link

@Sverre-W @r-kernberger did you tried the scenario which I have highlighted at your side? because to ensure that Retention options is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

4 participants