Skip to content

bug(updater): update leaves the main backend and workers running pre-update code — no restart after code sync #21343

Open
0 of 1 issue completed

Description

@mrveiss

Problem

After an update through the built-in updater, the new code is on disk for the main backend, the Celery worker and Celery beat, but those three services keep running the code they started with. Nothing tells the operator: health answers 200 and the version endpoint carries no commit.

Evidence (local deployment, read-only, 2026-11-11, Europe/Riga local time)

Update to commit 6cd72da98027 through the built-in updater; code sync ran 22:08-22:34.

Observation Value
SLM backend deployed-commit marker 6cd72da98027, written 22:32
SLM backend service restarted 22:32:44
Component sync markers autobot-backend, autobot_shared, autobot-slm-frontend, libs, autobot-plugins 6cd72da98027, written 22:31-22:33
New sources on disk backend entry module and the new eval/ package, dated 22:08
Main backend service, Celery worker service, Celery beat service all last started 17:11, i.e. before the code landed; never restarted
The update's Ansible log, backend play contains no restart step
Health endpoints 200 "healthy"
Version endpoint only {"version":"0.0.1","build":"dev"}, no commit

So changes merged today (#21216, #21247, #21273) are on disk but not live.

Code locations (origin/main, read from git show; static reading, not run)

  • autobot-slm-backend/ansible/playbooks/update-all-nodes.yml:1414-1421 restarts autobot-backend in Play 2, tagged restart, when: 'backend' in group_names.
  • update-all-nodes.yml:1439-1461 restarts autobot-celery and autobot-celery-beat (added for CRITICAL(deploy): update rewrites 2000+ .py files under the live interpreter — 22-minute window where late first-imports raise ImportError for symbols that exist #13539), same tag and group gate.
  • update-all-nodes.yml:855-856: Play 2 is hosts: infrastructure. Everything above lives in Play 2 only; Play 1 (:382) restarts the SLM backend (:734-739) and nginx for the SLM frontend (:757-761) and nothing else.
  • autobot-slm-backend/api/code_sync.py:3205-3225 (_ansible_self_update): runs update-all-nodes.yml detached with --limit = localhost plus co-located nodes. The restart of the SLM backend in Play 1 is what can cut this run.
  • autobot-slm-backend/services/sync_restart.py:20-24: "sync without restart" passes --skip-tags restart -e autobot_restart_services=false, so a code-only sync leaves every service on old code by design.
  • autobot-backend/initialization/endpoints.py:256 hard-codes "build": "dev"; no commit is exposed.

Root cause

Not established. The playbook on main does contain restart tasks for the backend and both Celery units, so the missing restart must come from one of: (a) Play 2 never ran or was cut when Play 1 restarted the SLM backend at 22:32:44 (same shape as open #12596); (b) the run was a code-only sync (--skip-tags restart); (c) the machine's inventory row is not in the backend group so the gate is false. Needs the run's PLAY header list and the --limit/--skip-tags it was started with. Tracked here as: whatever the cause, a successful update must not be able to end with stale processes, and a stale process must be detectable.

Related: #12596 (Play 2 skipped after the Play 1 restart), #13539 (restart of Celery added), #18052 (running tree vs code_source), #19444 (stale autobot_shared after self-update), #17645 (nothing reports the deployed commit), #20743 (no-restart sync).

Impact

Every "updated" deployment can silently run old code for the main backend and workers. Fixes appear deployed but are not, and host-evidence checks for acceptance criteria on any issue are invalid until the services are restarted.

Proposed fix (in the built-in updater only; no side-channel restarts)

  1. One canonical restart step driven by "this component's deployed commit changed", reused for every component and every long-running unit (main backend, Celery worker, Celery beat, workers), instead of per-play hand-written tasks.
  2. The update does not report success while any unit it manages started before its component's sync time; it reports which units are stale.
  3. The version endpoint (and health) return the commit the process was started from, so a stale process is detectable by comparing with the deployed-commit marker.

Acceptance criteria

Code-verifiable:

  • Every systemd unit the updater manages has a restart path notified by its component's sync, in one shared task/handler (file:line quoted).
  • A test/guard fails when a unit named in code_sync.py::_COMPONENT_SERVICES or update-all-nodes.yml restarts has no restart path.
  • The version endpoint returns the commit the process started from (test).
  • A "stale process" check compares process start with component sync time and is surfaced in update status (test).

Needs host evidence:

  • After an update through the built-in updater, each service's start time is later than its component's sync time (main backend, worker, beat).
  • The version endpoint on the local deployment shows the just-deployed commit.

Activity

  1. mrveiss commented on Nov 12, 2026

    @mrveiss
    OwnerAuthor

    Second host observation (2026-11-12, about 10:27 Riga time), after the install was updated to f87e78874a2e through the builtin updater. Read-only; nothing on the host was changed.

    Result: the gap persists in a narrower form. Files are deployed at the new commit; the SLM side is now restarted and rebuilt; the main backend, the Celery worker, Celery beat and the user frontend are still on pre-update state.

    What Observed
    Deployed files Backend marker records f87e78874a2e; four files changed by today's landed trains (autobot_shared/after_commit.py, knowledge/retrieval_invalidation.py, chat_workflow/stall_escalation.py, llc/services/work_item_import.py) are byte-identical to main
    Backend API, Celery worker, Celery beat Processes started 2026-11-11 about 17:11 — before the update; deployed modules are newer than the processes, so the code in memory is stale
    AI stack, NPU worker, TTS worker Also started 2026-11-11; stale if they load changed code (not determined)
    SLM backend, SLM agent, web server Restarted during the update (about 09:57)
    SLM frontend bundle Rebuilt during the update
    User frontend bundle Still the build from 2026-11-09; a string unique to a component landed today is absent from the served bundle

    Probable trigger (new evidence). The updater's first playbook run ended with one failed task: in the backend play, at the internal API key alignment step, on the manager host. The error detail is hidden by no_log; just before it the log shows a warning that the stored keys differ and none was rewritten. Everything ordered after that task in the play — restarting the main backend and Celery, building the user frontend — did not run. A second run reported no failures but matched no hosts for those plays and restarted nothing.

    So the update reports success-looking state (markers written, files in place) while the services that matter most keep running old code.

    What this adds to the acceptance criteria

    • A failed task in the update play fails the update visibly (status in the maintenance UI and in the updater's result), and the deployed-commit marker is not advanced past what is actually running.
    • The key-alignment step's failure is diagnosable without exposing secrets (which side differs, not the values).
    • After a successful update every long-running service that loads changed code has a start time after the update, and both frontend bundles are newer than the update.
    • The running backend reports the commit it was started from (today /api/version reports only a static version), so "what is running" can be checked without comparing process start times.

    Not observed: the hidden error text; whether the AI/NPU/TTS workers need a restart for these changes; whether database migrations ran.

  2. mrveiss commented on Nov 12, 2026

    @mrveiss
    OwnerAuthor

    Second sighting — update to 394642fe5fa1 (2026-11-12, ~15:01–15:05 Riga), read-only host check

    The updater run finished clean this time (play recap failed=0 on both targets), so the stale processes are not a consequence of the failed key-alignment step seen in the earlier run (#20750) — they occur on a successful update too.

    Check Result
    Version markers sync-commit markers in backend, shared, SLM frontend and SLM agent all hold 394642fe5fa1…; source tree HEAD equals it
    File content 6 files changed since the previous install compared by sha256 against 394642fe5f — all identical
    SLM backend / SLM agent / SLM admin UI restarted 15:02 — new code
    SLM frontend bundle rebuilt 15:01
    Main backend unit active since 11:40, process started 11:27 — old code in memory
    AI stack, Celery worker, Celery beat same, 11:27–11:41 — old code
    Vector store, NPU worker, browser worker, TTS worker units active since ~11:41 — before the update
    User frontend bundle served bundle still the 2026-11-09 build; no new build directory; the deployed user-frontend source files are also dated 2026-11-09
    Health main and SLM backends answer 200 — which only shows the processes are up

    So after a successful update the files on disk are current while every non-SLM service keeps running the previous code, and the user frontend is neither re-synced nor rebuilt. Anything landed today in the main backend, workers or user frontend has no host evidence until those are restarted/rebuilt by the updater.

    Not established: why the play skipped the restarts and the user-frontend sync/build (the self-update log is not readable to the checking account; the recap shows 129 skipped tasks on the node target).

  3. mrveiss commented on Nov 12, 2026

    @mrveiss
    OwnerAuthor

    Third check — update to 1b412de635c8 (2026-11-12, deploy window 18:41–18:45 Riga), read-only: cause located

    Correction to the previous comment: the updater log holds two runs per update. The failed=0 recap quoted earlier was the SECOND run (a remote node's agent only). The FIRST run — the one that deploys the main node — ended with failed=1 on the main node.

    Where it stops: task Internal key | Propose re-aligning the backend's key to the SLM's (#20750) fails (its output is hidden by no_log), and the fatal ends that host's play. Everything the play does after that point never runs on the main node:

    • no restart of the main backend, AI stack, Celery worker/beat, vector store, NPU / browser / TTS workers — all still the processes started at 11:06–11:07, i.e. old code in memory although the files on disk are new (6 of 6 spot-checked backend files match the commit by sha256);
    • no sync or build of the user frontend — its sync marker and served bundle are still from 2026-11-09, and a user-frontend source file changed today differs from the commit;
    • the AI stack, NPU worker and browser worker modules are not synced at all (markers from 2026-11-08).

    What does run before the abort: source fetch, backend/shared/SLM file sync, SLM agent + SLM backend restart, SLM frontend build.

    Just before the failing task, a warning task reports that the stored internal API key differs between the backend's two env files and the SLM, keeps each file's own key and rewrites nothing, because re-aligning a credential needs human approval (#17038). So the sequence is: mismatch detected → a proposal step is attempted → that step fails → the whole update of the main node is aborted.

    Why this matters: since the key mismatch appeared, no update has restarted the main services or shipped the user frontend. Every "installed at " since then means "files copied", not "running". No acceptance criterion that needs host evidence for the main backend, workers or user frontend can be met until this is fixed.

    Two separate things to fix:

    1. A step that only PROPOSES a credential change for human approval must not be fatal to the update: record the proposal (or the failure to record it) loudly, then continue with restarts and the frontend build. Whether a proposal could be recorded must be visible in the update summary.
    2. The key mismatch itself needs the owner's approval through the approval queue (Umbrella: SLM Data hygiene page — detect and safely clean up orphaned data across services #17038 / bug(secrets): every SLM System-vault call to the backend is refused (401) on the dev host; 0 of 118 succeeded in 7 days #20750) — it is not something the updater or an agent may resolve on its own.

    Not established: the error text of the failing task (hidden by no_log); whether the failures at the two earlier commits today had the same cause (their first-run recaps were not read).

  4. mrveiss commented on Nov 12, 2026

    @mrveiss
    OwnerAuthor

    Follow-up from reading the updater log and the playbook (fix proposed in PR #21399, not merged, not yet reviewed):

    • The proposal task failed on all seven update runs of 2026-11-12, each time about 2 ms after its banner — too fast for any HTTP exchange, so the failure happens on the controller before a result exists (a templating or condition error in the task's arguments is the working hypothesis; the text is hidden by no_log). The task already tolerates HTTP refusals, so the suspected key deadlock is not what aborts the play. This also confirms the same cause for the two earlier installs today.
    • What the abort skips on the main node: env regeneration and the database migration sequence, restart of the main backend, Celery worker and beat, the user-frontend sync/build/restart, the NPU, TTS and browser worker deploys and restarts, the AI-stack deploy and its restarts, the shared sync, the agent redeploy and the mark-synced step. Note the migrations in that list.
    • The restarts are inline tasks, not handlers, so no handler flush could have rescued them.

    PR #21399 wraps the propose/report/claim tasks in a block with a rescue so they can never fail the update, reports the non-secret shape of the failure (status, field names, error text unless it could name a key) in the update summary, rewrites no key and approves nothing. The real error text will be visible on the first update that runs with that change.

  5. mrveiss commented on Nov 12, 2026

    @mrveiss
    OwnerAuthor

    Root cause found by reading (unproven until an update runs): the updater's include sets the internal-key URL from infrastructure.ports.backend. Looking up infrastructure templates the whole dict in inventory/group_vars/infrastructure.yml, whose host entries index groups['<name>'][0] unguarded (the reserved_1 entry uses vnc_nodes, a group no inventory defines). That raises while the task's url is templated, before any HTTP call, so failed_when: false cannot absorb it and no_log hides it. It fits the ~2 ms failure on every run.
    PR #21399 builds the URL from the flat backend_port, guards the dict, and wraps the proposal step in a rescue that reports a key-free shape and lets the update continue. Keep this open until a host update shows the restarts, the rebuilt user frontend, and either a pending approval or the reported shape. Note: with the proposal not recorded, no approval row exists, so the maintenance UI shows nothing about it; only the update output and summary do.

  6. 12 remaining items

  7. mrveiss commented on Nov 13, 2026

    @mrveiss
    OwnerAuthor

    Sighting, 2026-11-13 (read-only observation of the local install after a self-update that reported failed=0):

    • The code-source checkout and the SLM backend are at 87819661d3; the SLM backend service was restarted by the run.
    • The main backend's installed source tree corresponds to 95511a1281 (305 commits behind), it carries no deployed-commit stamp, and its service has been running since before that tree was last synced (no restart).
    • So the main backend runs code older than both its own installed tree and the commit the update reported.

    This is a witness for this issue, not a new defect. Frontend half of the same observation: #18100.

  8. mrveiss commented on Nov 13, 2026

    @mrveiss
    OwnerAuthor

    Evidence from a second symptom of the update ordering: after an update the Custom Dashboard showed the toast "Could not load your saved dashboard layout. Editing is off so it cannot be overwritten." (`views.customDashboard.loadFailed`).

    • `useDashboardLayout.ts` sets `loadError` in exactly one place: the `apiClient.get(.../users/me/dashboard-layouts/{page})` call throwing (any non-2xx or network failure). Client-side shape/limit problems do not set it.
    • The dashboard-layout contract did not change: `git log --since=2026-11-12 origin/main -- autobot-backend/api/users.py autobot-backend/api/schemas_users_dashboard_layouts.py autobot-frontend/src/composables/dashboard` is empty. So this is not contract skew and not a stored-layout compatibility problem.
    • The earlier dashboard-layout requests in the backend log are 200 (company-os layout) and one 401 (home, expired session). The failing request never appears in the backend log.
    • The backend was stopped and restarted by the update run: shutdown logged 07:57, new process started 07:59:08, and the proxy error log shows connection-refused to the backend upstream for the whole gap (one request every 15 s, 9 in the window). A page load in that gap gets a 502, which sets `loadError`.
    • Nothing retries: the toast stays until a manual reload, and editing stays off.

    Cause verdict: transient, caused by the frontend being published and served before the backend is back. It will not persist once the backend is up and the page is reloaded. Not established: the exact status of the failed request (the proxy access log is empty/disabled, so the 502 is inferred from the upstream errors).

    Suggested additions to this issue: (1) order the update so the frontend is only switched after the backend answers its health check, (2) `useDashboardLayout.load()` retries with backoff on network/5xx and the view offers a Retry action instead of a dead-end toast (CustomDashboard.vue ~388). AC: after an update the dashboard loads the saved layout without a manual reload.

  9. mrveiss commented on Nov 13, 2026

    @mrveiss
    OwnerAuthor

    Host evidence 2026-11-13 — why the app services are not restarted

    Evidence

    • Topology: the app services (backend, celery, celery-beat, ai-stack, chromadb, npu, playwright, tts) run on the same machine as the SLM, registered as node 00-SLM-Manager (its address is local to that machine). The second node in the update (b9a29e04, different address, not local) is a separate machine that only receives Play 2's shared-code and agent tasks (recap ok=113 skipped=129 in every run). Its 129 skips are therefore expected and are not this defect.
    • The co-located node IS in Play 2 and in the backend group when Play 2 reaches it: the log shows [PLAY 2] Backend | Restart service on 00-SLM-Manager in updates on 2026-11-06, -07 and -08 (last: 2026-11-08 11:45, recap ok=616 failed=0). No later update contains that task (zgrep -c = 0 in logs from 2026-11-09 on).
    • Since 2026-11-08 15:23, every update that touched 00-SLM-Manager ended failed=1 for that host (14 failures in the retained logs). 13 died in Play 2 at Internal key | Propose re-aligning the backend's key to the SLM's (#20750) (no_log, so the cause is censored), before Backend | Restart service. Ansible drops a failed host from all later plays, so the backend, celery and the other services never restarted. The follow-up run then limits to the remaining node, so the SLM host is not retried.
    • Today 07:36 the run died earlier, in Play 1 (slm_manager : SLM | Deploy nginx configuration, template recursion, fixed separately in fix(updater): the SLM play no longer recurses on infrastructure host addresses (#21343) #21461), so Play 2 never started for the SLM host. The Play 1 restart that did run was only autobot-slm-backend (and the SLM agent).
    • Both bug(updater): update leaves the main backend and workers running pre-update code — no restart after code sync #21343 fixes for the propose task (cc6452c, 2efc171) are ancestors of the deployed commit (8781966). No update has yet reached that task with them, so they are untested on this install.
    • Not caused by the update: from 07:54 per-role playbook runs (Setup AI Stack Node, Deploy AutoBot Role x2, Setup Browser Worker Node) ran against 00-SLM-Manager with a registry-built inventory. They restarted chromadb/ai-stack (07:56) and autobot-backend/celery (07:59). At last check celery-beat, npu-worker, playwright and tts-worker were still running since 2026-11-12 11:40. The launching API route is not established (no route line in the readable logs).
    • Not established: what restarted all units at 2026-11-12 11:40 (no ansible run logged then; the machine booted 2026-11-11); the node registry roles (database not readable without credentials; API needs auth); the temp inventory (directory unreadable).

    Root cause (established vs not)

    Options

    1. Re-run the builtin update once fix(updater): the SLM play no longer recurses on infrastructure host addresses (#21343) #21461 is in the deployed code; the Play 2 fixes from bug(updater): update leaves the main backend and workers running pre-update code — no restart after code sync #21343 are already deployed. No decision needed.
    2. If Play 2 still fails for the SLM host, make the failure visible: drop no_log on the status line only (log HTTP status, never the key) in autobot-slm-backend/ansible/_shared/tasks/realign_internal_api_key_claim.yml. Small PR, no decision needed.
    3. Make Play 1 failure not skip co-located app restarts (e.g. restart the co-located app services in Play 1 or run Play 2 with any_errors_fatal: false semantics for the SLM host). Needs an owner decision.
    4. Any registry role change is only a proposal needing human approval (not needed on current evidence).

    What the next update must show

    • [PLAY 2] Backend | Restart service and the celery restart tasks executed on the SLM host, recap failed=0 for it.
    • systemctl show -p ActiveEnterTimestamp for backend, celery, celery-beat, npu, playwright and tts later than the update start.
    • The summary line from internal_api_key_realign_report if the key mismatch persists.
  10. mrveiss commented on Nov 13, 2026

    @mrveiss
    OwnerAuthor

    PR #21461 merged as 0f14a1b. It removes the template recursion that stopped the manager play (the infrastructure variable no longer reads itself; a cycle guard covers group variables, role defaults and inventories). This issue stays open: the restart half is only provable on a host. The next update through the builtin updater must show the nginx configuration task ok, Backend | Restart service and the Celery restart on the manager host, recap failed=0, and service start times later than the update start. Side effect tracked separately in #21465.

  11. github-actions commented on Nov 13, 2026

    @github-actions
    Contributor

    Landed in #21461, merge 0f14a1b496

  12. mrveiss commented on Nov 13, 2026

    @mrveiss
    OwnerAuthor

    Host evidence, deployed node, update to 470d3627d8 on 2026-11-13/14 (Riga time), read-only observation:

    Check Result
    Deployed-commit markers (every component) 470d3627d8d5, written 23:57–00:01
    SLM backend started 23:58:52
    Main backend started 23:59:47
    Celery worker / beat started 23:59:55 / 23:59:59
    TTS worker, browser worker, AI stack, vector store, NPU worker started 00:01:22 – 00:02:52
    Restart counters since start 0 on all nine units
    Failed AutoBot units none
    Backend health endpoint 200
    Error-priority journal lines since restart (main backend, SLM backend) 0 / 0
    Live frontend builds (user app / admin app) built 00:00 / 23:57

    Every service's start time falls inside the update window, after its code was written — the update restarted the main backend and the workers. This is the first update since #21461 landed; the previous attempt aborted in the SLM play before any restart.

    This is one update. The acceptance criteria stay unchecked here until a second update shows the same.

  13. mrveiss commented on Nov 14, 2026

    @mrveiss
    OwnerAuthor

    Second update through the built-in updater, deployed node, to 78aca82701 (2026-11-14, Riga time), read-only observation:

    Check Result
    Component sync markers 78aca8270188, written 02:23–02:25
    SLM backend started 02:24:30
    Main backend / Celery worker / beat started 02:26:22 / 02:26:31 / 02:26:36
    TTS worker, browser worker, AI stack, vector store, NPU worker started 02:28:08 – 02:30:00
    Restart counters since start 0 on all nine units; no failed AutoBot unit
    Backend health endpoint 200
    Error-priority journal lines since restart (main / SLM backend) 0 / 0

    Same result as the update to 470d3627d8 two hours earlier (comment above): on two consecutive updates every service started after its component's sync. Ticked on that evidence: "each service's start time is later than its component's sync time (main backend, worker, beat)".

    Not ticked: "The version endpoint on the local deployment shows the just-deployed commit" — GET /api/version on the node answers {"version":"0.0.1","build":"dev",…} with no commit, so that criterion (and the code criterion for the endpoint) is not delivered. The four code criteria were not examined in this pass.

  14. mrveiss commented on Nov 20, 2026

    @mrveiss
    OwnerAuthor

    Sighting (2026-11-20): after the builtin self-update to edb71ca at 10:37 Riga, the browser worker (node /opt/autobot/autobot-browser-worker/playwright-server.js) was still the process started 2026-11-19 22:38. It was not restarted. A witness for this issue. Separately, its files were not synced either; that is tracked on its own issue.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions