a-eye icon indicating copy to clipboard operation
a-eye copied to clipboard

fix: resume processing automatically after container restart

Open martindell opened this issue 7 months ago • 3 comments

Problem

After a container restart (whether from a crash, manual restart, or Unraid maintenance), a-eye silently stalls and never resumes processing. Two separate bugs combine to cause this:

Bug 1 - Stuck "processing" items block the queue

If the container stops while images are being processed, those images are left in status = 'processing' in the database permanently. On the next startup, these items are never recovered, permanently blocking the worker queue.

Bug 2 - Pending items are never re-enqueued

The worker queue is in-memory only. On startup it is always empty, regardless of how many status = 'pending' items exist in the database. There is no mechanism to reload them — meaning after any restart, processing simply never resumes unless the user manually triggers it through the UI (and knows they need to).

In practice both bugs together mean: restart the container → processing stops forever with no error message.

Fix

Two small additions to the startup lifespan() function in backend/main.py:

  1. Immediately after DB init - reset any stuck processing items back to pending, with a log message counting how many were recovered.
  2. Immediately after the worker starts - load all pending items from the database into the worker queue, with a log message counting how many were enqueued.

Both operations are cheap (single SQL query each), happen at startup only, and are no-ops on a clean first run.

Testing

  1. Start a-eye with a backlog of pending images and let it begin processing
  2. Restart the container mid-processing
  3. Before this fix: processing stops permanently with no error
  4. After this fix: processing resumes automatically within seconds, and the logs show:
Startup recovery: reset N stuck 'processing' image(s) to 'pending'
Startup recovery: enqueued N pending image(s) for processing

martindell avatar Apr 18 '26 06:04 martindell

Nice! Thanks for working this out @martindell. I made the changes inside the container, rebooted and it is now processing again. Only 89717 XMP descriptions to go! :D

Edit: A second reboot removed my patch, so I ended up adding the main.py on my Unraid server in appdata and adding another path to the container replacing the main.py inside the container, with the patched version from appdata. Now it works like a charm through reboots. Thanks again!

ishemes avatar Apr 18 '26 20:04 ishemes

Thanks @martindell, worked great for a stuck process.

iwantatr8 avatar Apr 23 '26 08:04 iwantatr8

Looking forward to this change, I am trying to run this on a 12 year old server with no GPU, it was slow originally but now it is completely stuck.

MrBeardSmith avatar May 20 '26 19:05 MrBeardSmith