History clean up job configuration setup

In ACT_HI_JOB_LOG table, column JOB_STATE_ has values like 0 & 2, what is meant by 0 & 2 and what are all the possible values?

image

When jobs successfully done, the state is 2 in database. You can find all value in source code.

  JobState CREATED = new JobStateImpl(0, "created");
  JobState FAILED = new JobStateImpl(1, "failed");
  JobState SUCCESSFUL = new JobStateImpl(2, "successful");
  JobState DELETED = new JobStateImpl(3, "deleted");

In my case few jobs are in created state, its neither failed nor successful.

Hi @aravindhrs,

If you look why some jobs are not being execute (just guessing), I think this blog post might be interesting read for you:
https://blog.camunda.com/post/2019/10/job-executor-what-is-going-on-in-my-process-engine/

@Yana thanks for your reply.

If i need to schedule history cleanup batch window jobs only on weekends, below configuration is sufficient?

<!-- overriding batch window for saturday and sunday -->
<property name="saturdayHistoryCleanupBatchWindowStartTime">06:00</property>
<property name="saturdayHistoryCleanupBatchWindowEndTime">06:00</property>
<property name="sundayHistoryCleanupBatchWindowStartTime">06:00</property>
<property name="sundayHistoryCleanupBatchWindowEndTime">06:00</property>

or its mandatory to configure below one also?

<property name="historyCleanupBatchWindowStartTime">20:00</property>
<property name="historyCleanupBatchWindowEndTime">06:00</property>

My requirement is i don’t want to run history cleanup on daily basis, rather i would prefer history cleanup on only weekends. Which configuration suits my needs?

Yes, it is sufficient, do you have some trouble with it? If it is the case could you please let us know what is your setup - Camunda version, database type and version,…

1 Like

My query is regarding whether it’s mandatory to configure below history cleanup for Saturday and Sunday history cleanup batch window job.

<property name="historyCleanupBatchWindowStartTime">20:00</property>
<property name="historyCleanupBatchWindowEndTime">06:00</property>

You don’t need to setup these start and end time:

<property name="historyCleanupBatchWindowStartTime">20:00</property>
<property name="historyCleanupBatchWindowEndTime">06:00</property>

if you want to setup only the weekend.

1 Like

Thanks. That’s what I needed

How to trigger history cleanup manually?

There are three options:

After manual trigger, the cleanup will run until there are no more instances to cleanup.

2 Likes

I have setup batch windows for history cleanup.

And if i try to call Rest API: post-history-cleanup which one takes precedence?

I hope calling rest api also schedules batch job. or it will clean the instances based on history removal strategies immediately by calling rest api?

Depends on the passed executeAtOnce param:

When true the job will be scheduled for nearest future. When false, the job will be scheduled for next batch window start time. Default is true.

I didn’t set executeAtOnce = true|false. So it will consider default value as true.

On what basis the date is picked for history cleanup? Next day or some random date engine will pick and schedule?

When i call rest api on 2019-10-31, i got this duedate(next day) from below json response. Also i have setup batch windows for history cleanup on Saturday & sunday (18:00+0530) RFC822 Timezone.

{
    "id": "3a136686-fb31-11e9-b869-507b9dc4ed46",
    "jobDefinitionId": null,
    "processInstanceId": null,
    "processDefinitionId": null,
    "processDefinitionKey": null,
    "executionId": null,
    "exceptionMessage": null,
    "retries": 3,
    "dueDate": "2019-11-01T00:36:27.255+0530",
    "suspended": false,
    "priority": 0,
    "tenantId": null,
    "createTime": "2019-10-30T21:50:46.000+0530"
}

“When true the job will be scheduled for nearest future.”
After a manual trigger, a job will be created (if it doesn’t exist) and it will be picked up by the Job Executor which will schedule the job. In case the history cleanup job exist the due date will be changed (to current moment) so it can be picked by the Job Executor.

Keep in mind if there are too many job available for execution, the cleanup job can be rescheduled in case the Job Executor is not fast enough in execution.

@Yana Do you mean we shouldn’t create multiple history cleanup jobs?

No, no, I was talking about jobs in general. I didn’t apply it for the parallelization of the History cleanup.
I just wanted to explain further why the History cleanup will not run immediately, but as a regular job, it will be scheduled for the nearest future.
I hope it is more clear now.

@Yana Got it. Thanks for the reply :blush: