Reliable file processing recovery

File processing
- Fixed recovery failures that could leave background file processing and cleanup work stuck after a restart.
- Improved safe retry behavior across database modes so completed work stays protected while pending work resumes.