kagkarlsson / db-scheduler

Persistent cluster-friendly scheduler for Java
Apache License 2.0
1.23k stars 188 forks source link

Unresolved execution detection never deletes old tasks if service restarts too often #515

Open GeorgEchterling opened 1 month ago

GeorgEchterling commented 1 month ago

Expected Behavior

The unresolved execution detection should delete unresolved tasks once they have been due for the duration configured in deleteUnresolvedAfter. (Default: 14 days)

Current Behavior

The unresolved execution detection only deletes unresolved tasks after the local scheduler instance has detected the unresolved task for the configured duration. If the service never runs for that duration (due to updates or restarts), unresolved tasks are never deleted.

If this is the intended behaviour, it should be documented.

Workaround: I've reduced deleteUnresolvedAfter to 3 days, since the service regularly receives updates and never runs for 14 days straight.

Steps to Reproduce the bug

  1. Create a recurring task
  2. Delete the task implementation
  3. Restart the scheduler
  4. Restart the scheduler before the timeout configured in deleteUnresolvedAfter
  5. The task won't be deleted until deleteUnresolvedAfter after the latest restart

Context

kagkarlsson commented 1 month ago

Yes, you are correct. It should be changed to age = now - execution-time