Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions inc/connector/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,14 @@ function pre_unschedule_event( $pre, $timestamp, $hook, $args, $wp_error = false

$job = $jobs[0];

// Delete it.
$job->delete();
// Check if the job is running more then 3 hours from the timestamp.
$is_delete_running = ( time() - $job->start ) > 10800;
if ( $is_delete_running ) {
$job->delete( [ 'delete_running' => $is_delete_running ] );
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than being this opinionated in the Cavalcade code itself, could we introduce a filter cavalcade/job-max-runtime which defaults to false, but lets a project opt in to this behavior when set?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue when I try to fix this on another project was, if the job is running status and stalled, it cannot be deleted from wp_unschedule_event triggered from cron delete from cli.

Although I agree on the max time out is up to project to decide.

} else {
// Delete it.
$job->delete();
}

return true;
}
Expand Down