Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions inc/Abilities/Engine/ExecuteStepAbility.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ public function execute( array $input ): array {
$job_id = (int) ( $input['job_id'] ?? 0 );
$flow_step_id = (string) ( $input['flow_step_id'] ?? '' );

// Transition job to 'processing' now that Action Scheduler is actually
// executing it. For parent jobs this is a no-op (already processing via
// RunFlowAbility). For batch child jobs this is the real transition from
// 'pending' → 'processing', ensuring recover-stuck only catches jobs
// that genuinely started but never finished.
$this->db_jobs->start_job( $job_id );

try {
$engine_snapshot = datamachine_get_engine_data( $job_id );
$engine = new EngineData( $engine_snapshot, $job_id );
Expand Down
5 changes: 4 additions & 1 deletion inc/Abilities/Engine/PipelineBatchScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ private function createChildJob(
}

datamachine_set_engine_data( $child_job_id, $child_engine );
$this->db_jobs->start_job( $child_job_id );

// Child job stays 'pending' until Action Scheduler actually picks it up.
// ExecuteStepAbility transitions to 'processing' at execution time,
// so recover-stuck only catches genuinely stuck jobs.

// Schedule the next step with this single DataPacket.
// Uses the normal engine path — the child is a real pipeline job.
Expand Down
11 changes: 8 additions & 3 deletions inc/Engine/Tasks/TaskScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ public static function schedule( string $taskType, array $params, array $context
'scheduled_at' => current_time( 'mysql' ),
) ) );

// Mark job as processing.
$jobs_db->start_job( (int) $job_id, JobStatus::PROCESSING );
// Job stays 'pending' until Action Scheduler fires handleTask().
// The transition to 'processing' happens there, so recover-stuck
// only catches jobs that genuinely started but never finished.

// Schedule Action Scheduler action.
if ( function_exists( 'as_schedule_single_action' ) ) {
Expand Down Expand Up @@ -448,7 +449,11 @@ public static function processBatchChunk( string $batchId ): void {
*/
public static function handleTask( int $jobId ): void {
$jobs_db = new Jobs();
$job = $jobs_db->get_job( $jobId );

// Transition from 'pending' → 'processing' now that AS is running this.
$jobs_db->start_job( $jobId, JobStatus::PROCESSING );

$job = $jobs_db->get_job( $jobId );

if ( ! $job ) {
do_action(
Expand Down
Loading