Failing background jobs.;Failed to run background job #1 'BackgroundJobSearchIndex' 10 time(s)

Hi @chesty

I had something similar today. My problem was the there was a wrong data type stored in user preferences.

Can you execute the following via “zammad run rails c” and can you tell if you still have failing jobs?

items = SearchIndexBackend.search('preferences.notification_sound.enabled:*', 3000, 'User')
items.each {|item|
  next if !item[:id]
  user = User.find_by(id: item[:id])
  next if !user
  next if !user.preferences
  next if !user.preferences[:notification_sound]
  next if !user.preferences[:notification_sound][:enabled]
  if user.preferences[:notification_sound][:enabled] == 'true'
    user.preferences[:notification_sound][:enabled] = true
    user.save!
    next
  end
  next if user.preferences[:notification_sound][:enabled] != 'false'
  user.preferences[:notification_sound][:enabled] = false
  user.save!
  next
}

Delayed::Job.all.each {|job|
  Delayed::Worker.new.run(job)
} 

Feedback is appreciated.

-Martin

3 Likes