Repository navigation
fix(ops-agent): release a traffic maintenance fence its own restart left behind - #693
Merged
Merged
Conversation
…eft behind When the operations agent was stopped during `valhalla.traffic.maintain` (an update recreating it, a crash, a reboot), the journal failed the job as `recovery_required`, but its fence stayed. Valhalla stayed stopped and data-manager's supervisor kept its worker paused without a word, and that worker is the only one that asks for the next maintenance. At start the agent now matches the fence to its journal job. When that job was interrupted, it removes the job's tool container, confirms Valhalla is stopped, withdraws the generation manifests and keeps the fence as `.traffic-maintenance.interrupted-<id>.json`; the worker then requests a fresh, coordinated maintenance. A job that failed on its own keeps its fence for an operator. The supervisor now logs why its worker is paused, warns while a pause outlasts any maintenance, and logs the resume. The monitoring guide describes these pauses and the manual recovery after a failed maintenance.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
What changed and why
An update recreated the operations agent while it was rebuilding the Valhalla traffic extract (
valhalla.traffic.maintain). The journal correctly failed the job asrecovery_required, but its fencevalhalla/osm-pbf/.traffic-maintenance.jsonstayed. Valhalla stayed stopped, and data-manager's supervisor kept its worker paused without logging anything. That worker is the only component that requests the next maintenance, so nothing could recover. On openmapx.com this lasted about 8 hours (2026-10-30 15:45 UTC until a manual recovery):Operations agent. At startup, right after the journal opens,
recoverInterruptedTrafficMaintenancematches the fence to its job: same fingerprint, and the fence written within that job's deadline after its submission. Every rebuild shares one fingerprint, and only interrupted jobs outlive the journal's retention, so the time check keeps an old record from claiming a newer fence.When the matched job was interrupted, the agent:
openmapx-valhalla-maint-*container and confirms it is gone,traffic-generations.jsonandtraffic-generations.unverified.json,.traffic-maintenance.interrupted-<id>.jsonand removes it.The worker then resumes, the next inspection reports
not_ready, and the worker requests a fresh coordinated maintenance. This automates the manual recovery used on openmapx.com, which completed in 177 s.A job that failed on its own keeps its fence, because retrying a broken graph would only fail again. The agent leaves the fence in place and logs why whenever it can't prove these conditions: no matching job, a container that survives removal, or Valhalla still running.
The fence lives where data-manager can write, so it is read through a new bounded, symlink-refusing
AnchoredDirectory.readFile, and only plan-shaped values from it are logged.Data manager. The supervisor logs once when it pauses its worker for maintenance (job, plan, start time), warns every 30 minutes once a pause outlasts any maintenance, and logs the resume.
Docs. The monitoring guide gains the two log lines and a "Graph maintenance pauses" section with the manual recovery for a maintenance that failed on its own. The engine verification notes describe the release.
Verification
readFile(bounded, absent, symlink, directory) and for the supervisor's pause reporting.operationIdwas checked against the production journal: it equals the interrupted job'sfingerprint.vitest --project node: 1362 files, 18,504 tests passed.apps/ops-agentand the supervision tests passed again after the last edits.tsc --noEmitfor@openmapx/ops-agentand@openmapx/data-manager, Biome and Prettier: clean.verify:traffic-maintenanceprobe, and a real agent restart during maintenance. Linux descriptor-anchored reads are covered only by the Linux CI leg of the anchored-directory tests.Not addressed here: updates still recreate the agent while it runs an async job. This change makes that recoverable, not avoided.
Release and upgrade impact
Product impact: ordinary