@@ -542,19 +542,22 @@ impl BackfillClient {
542542 pub async fn process_failed_jobs ( & self ) -> Result < u32 , BackfillError > {
543543 // Find jobs that have failed permanently (attempts >= max_attempts)
544544 // and haven't been processed yet
545- // Note: The jobs view doesn't include payload, so we'll handle this limitation
546545 let find_failed_jobs_query = format ! (
547546 r#"
548- SELECT id, task_identifier, queue_name, priority, key as job_key,
549- max_attempts, attempts, last_error, created_at, run_at, updated_at
550- FROM {}.jobs
551- WHERE attempts >= max_attempts
552- AND max_attempts > 0
553- AND id NOT IN (SELECT COALESCE(original_job_id, -1) FROM {}.backfill_dlq)
554- ORDER BY updated_at ASC
547+ SELECT jobs.id, tasks.identifier AS task_identifier,
548+ job_queues.queue_name, jobs.priority, jobs.key as job_key,
549+ jobs.max_attempts, jobs.attempts, jobs.last_error,
550+ jobs.created_at, jobs.run_at, jobs.updated_at, jobs.payload
551+ FROM {}._private_jobs AS jobs
552+ INNER JOIN {}._private_tasks AS tasks ON tasks.id = jobs.task_id
553+ LEFT JOIN {}._private_job_queues AS job_queues ON job_queues.id = jobs.job_queue_id
554+ WHERE jobs.attempts >= jobs.max_attempts
555+ AND jobs.max_attempts > 0
556+ AND jobs.id NOT IN (SELECT COALESCE(original_job_id, -1) FROM {}.backfill_dlq)
557+ ORDER BY jobs.updated_at ASC
555558 LIMIT 100
556559 "# ,
557- self . schema, self . schema
560+ self . schema, self . schema, self . schema , self . schema
558561 ) ;
559562
560563 let failed_jobs = sqlx:: query ( & find_failed_jobs_query) . fetch_all ( & self . pool ) . await ?;
@@ -564,8 +567,7 @@ impl BackfillClient {
564567 for job_row in failed_jobs {
565568 let job_id: i64 = job_row. get ( "id" ) ;
566569 let task_identifier: String = job_row. get ( "task_identifier" ) ;
567- // Payload is not available in the jobs view, use empty object as placeholder
568- let payload = serde_json:: json!( { } ) ;
570+ let payload: serde_json:: Value = job_row. get ( "payload" ) ;
569571 let queue_name: Option < String > = job_row. get ( "queue_name" ) ;
570572 let queue_name = queue_name. unwrap_or_else ( || "default" . to_string ( ) ) ;
571573 let priority: i16 = job_row. get ( "priority" ) ;
0 commit comments