Queue-on-conflict retry for skipped scheduled scans + log handler session recovery (v2.6.39)#48
Merged
ttlequals0 merged 1 commit intomainfrom Apr 20, 2026
Merged
Conversation
…sion recovery (v2.6.39) Scheduled scans whose cron fire overlapped another in-progress scan were silently dropped: APScheduler consumed the fire and advanced next_run to the following cron interval, so a weekly Sunday 02:00 cleanup could go missing for a full week. MediaScheduler now queues a one-shot date-trigger retry (SCHEDULE_RETRY_DELAY_MINUTES, default 10), SCHEDULE_RETRY_MAX_COUNT times (default 6), and clears the retry state as soon as a scan actually starts. Applies to _run_scheduled_scan, _run_periodic_scan, and the env-var _run_cleanup HTTP 409 path. DatabaseLogHandler could get stuck after a flush failure: rollback() was attempted in a silent try/except, so when the rollback itself failed (stale connection, broken pipe) the scoped session stayed in "rollback() fully before proceeding" state for the life of the writer thread, producing a flood of "Failed to flush N log entries" lines. Added db.session.remove() after rollback and rate-limited the stderr report to once per 60s so recurring failures still surface.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MediaSchedulernow queues a one-shot date-trigger retry when a cron fire is skipped because another scan is running. Configurable viaSCHEDULE_RETRY_DELAY_MINUTES(default 10) andSCHEDULE_RETRY_MAX_COUNT(default 6). Retry state clears as soon as a scan actually starts.DatabaseLogHandlerrecovers from a failed flush: addsdb.session.remove()after rollback so the scoped session isn't stuck in "rollback() fully before proceeding" state for the life of the writer thread; rate-limits the stderr report to once per 60s.Version
2.6.39(bumped from2.6.38).Test plan
_queue_conflict_retry(queue, cap, clear, add_job-failure rollback, malformed env var) and 1 expanded test forDatabaseLogHandlerflush recovery (rollback+remove path, throttle window expiry)2.6.39built forlinux/amd64and pushed to Docker Hub (also taggedlatest)/api/versionreports2.6.39queued retrywarning appears and the retry firesFailed to flushstderr lines stop flooding