Skip to content

bug(deploy): backend role leaves autobot-backend DEAD if any task fails between stop(213) and start(883) → login outage #12139

Description

@mrveiss

Incident (live, 2026-07-23 12:01)

A deploy run stopped autobot-backend and never restarted it — dead from 12:01 to 12:48 (manual systemctl start). All /api/* → 502 → users could not log in; chat-delete failed with 'Network Error'. Manually recovered.

Root cause

roles/backend/tasks/main.yml: 'Stop service before env update (MVA-1633)' (line ~213, state: stopped) runs, then ~670 lines of risky work (apt install, pip install, code sync, alembic migrations, ownership fixes) execute BEFORE the service is started again (state: started at line ~883). If ANY task in that window fails — OR the ansible run is killed mid-flight (the #11492 self-restart-kills-the-run scenario, still live until #11492 is deployed under the running executor) — the backend is left STOPPED with no auto-restart. Compounding: the unit re-render (line 177) + daemon_reload (line 207) triggers systemd's 'Current command vanished from the unit file, execution won't be resumed', which stops the running backend even before the explicit stop.

Fix

Guarantee the backend ALWAYS ends started regardless of mid-deploy failure: wrap the stop→(heavy work)→start sequence in an ansible block with an always: clause that runs systemd: name=autobot-backend state=started daemon_reload=true (failed_when: false so the always never aborts). Idempotent on success; recovers the service on any block failure. (Process-KILL case is separately covered by #11492's detach once deployed; this handles task failures.) Consider also shrinking the stop→start window (stop only around the env-template deploy, not the whole role) as a follow-up. Apply the same guarantee to celery/celery-beat if they share the pattern.

Verify

An intentionally-failing task in the middle of the role must leave autobot-backend RUNNING (not dead). Part of umbrella #11820.

Activity

  1. mrveiss commented on Jul 23, 2026

    @mrveiss
    OwnerAuthor

    Closed — merged via #12140. Wrapped the backend role's stop→heavy-work→start window (56 tasks) in a block/always: on any mid-deploy task failure the always force-starts autobot-backend (state=started, failed_when:false), so the backend can never be left DEAD like today's 12:01 outage. All 90 tasks preserved (semantic diff identical). Process-kill case covered by #11492's detach once deployed.

  2. github-actions commented on Jul 23, 2026

    @github-actions
    Contributor

    PR #12140 (merged to Dev_new_gui) references this issue with a close keyword.

    fix(deploy): always-restart guard so backend can't be left dead on mid-deploy failure (#12139, #11820)

    If this issue is fully resolved, close it manually. If work remains, no action is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions