huginn: Please add button to 'Background Jobs' for remove stuck job

If you stopped the docker images the Job is only stuck in the database. The only way to remove it is to manually delete the database row.

# get a shell inside the docker container (replace huginn with the name or id of the container)
docker exec -it huginn /bin/bash

# source the environment file
source .env

# get a rails console
bundle exec rails console

# inside the rails console delete  the job 
Delayed::Job.where('locked_at IS NOT NULL AND locked_by IS NOT NULL AND failed_at IS NULL').destroy_all

_Originally posted by @dsander in https://github.com/huginn/huginn/issues/1988#issuecomment-548334831_

@dsander

After a few months of stable running, this problem appeared again this morning, hundreds of jobs were stuck, I tried your method and it was really useful!

There are already three buttons in the ‘Background Jobs’ page, Can you add another button to execute this command? In this case, when users encounter similar situations, they do not have to log in to the VPS every time to execute the code.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 19 (1 by maintainers)

Most upvoted comments

These stuck jobs are very common Website Agent, it may take up to tens of seconds to complete the execution generally, I think it seems unlikely that it will take several hours to complete the task.

Now that I know how to export the log, if I encounter this again next time, I will try to provide the log for your analysis here.

Thank you very much!

Adding the button should not be much work, but I am not sure in which cases it would help. The jobs should only get stuck when the background processor failed for some reason.

Didn’t you also need to restart the docker container to unstuck the process?

Not need to restart docker at least this time. When I found out, that job was stuck for about seven or eight hours, with dozens of pages of queued jobs following up. Using the buttons on the page can not remove this stuck job, I click ‘Remove all jobs’ to remove all queued jobs first, then login into VPS to run that code, the stuck task is successfully removed. After a while, a lot of queued tasks appeared in ‘Background Jobs’ again, but none of them were running, so I randomly found an Agent to perform a Dry Run, and everything was running normally.