Repository navigation
fix(sync): recover stuck offline recordings and enumerate current-firmware devices - #10397
Merged
Merged
Conversation
Restore the dispatch-agnostic stale-job finalizer: a job stuck in 'processing' past STALE_THRESHOLD_SECONDS is failed on read (get_sync_job), so the client reverts the WAL to 'miss' and re-uploads within ~10 minutes instead of sitting at 'Uploaded · processing on Omi' until the 24h TTL. The finalizer had been narrowed to a client-poll, cloud_tasks-only path, which left inline/BYOK jobs — and any job whose client stopped polling — stranded for 24h. The pipeline heartbeats updated_at at every stage and per segment, so 600s of silence only ever means the worker is gone. 'queued' jobs stay exempt: no worker has claimed them, and failing them caused spurious retry loops (#7469).
Background and auto-sync discovery read firmwareRevision off the raw connect
object, which is frequently still 'Unknown'. isRingBufferFirmware('Unknown') is
false, so ring-buffer devices — firmware 3.0.20 and up, the current firmware —
were routed to the multi-file enumerator, which returns nothing for them. Their
offline recordings were never enumerated, never uploaded, and never became
conversations unless the user happened to open the Auto Sync page, the one
caller that already passed the enriched value.
setDevice now carries the firmware resolved by getDeviceInfo, and both
discovery paths prefer it, falling back to the raw value so behavior is never
worse than before.
The backfill lane uploaded three files per batch, so recovering a backlog of offline recordings crawled. The two lanes exist to keep rate-limit domains apart — a backfill cooldown must not stall a freshly captured recording — not to throttle throughput, so both lanes now share one batch limit. The backend caps multipart part size (200 MB), not file count, and the fresh lane has been sending twenty files per batch already.
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.
Closes #10033. Closes #10197.
Offline recordings upload and then sit at "Uploaded · processing on Omi" for
12+ hours without becoming conversations, some never sync at all, and stuck
recordings never retry. Three independent causes, each fixed here.
1. Stuck sync jobs never self-healed (backend)
A job whose worker died stayed in
processinguntil the 24h reconcile TTL, sothe client polled a job that would never finish.
get_sync_jobused to finalize anyprocessingjob quiet pastSTALE_THRESHOLD_SECONDS(600s) tofailed, on every read and for everydispatch mode. That finalizer was later moved to the status-poll endpoint and
gated on
dispatch_mode == 'cloud_tasks', which left inline/BYOK jobs with noself-heal at all and made every other job depend on a client actively polling.
Restored the original behaviour. The pipeline heartbeats
updated_atat everystage and per segment, so 600s of silence only ever means the worker is gone.
queuedjobs stay exempt — no worker has claimed them, and failing them causedthe spurious "retrying" loops in #7469.
This fixes the reported symptom end to end: the client already reverts a WAL
from
uploadedtomissand re-uploads when the server reportsfailed, so adead job now recovers in ~10 minutes instead of 24 hours.
2. Ring-buffer devices were never enumerated in auto-sync (app)
Background and auto-sync discovery read
firmwareRevisionoff the raw connectobject, which is frequently still
'Unknown'.isRingBufferFirmware('Unknown')is false, so devices on firmware 3.0.20 and up — the current firmware — were
routed to the multi-file enumerator, which returns nothing for them. Their
offline recordings were never enumerated, never uploaded, and never became
conversations, unless the user happened to open the Auto Sync page, the one
caller that already passed the enriched firmware.
setDevicenow carries the firmware resolved bygetDeviceInfo, and bothdiscovery paths prefer it, falling back to the raw value so behaviour is never
worse than before.
3. Offline backlogs drained a few files at a time (app)
The backfill lane uploaded three files per batch, so recovering a backlog
crawled. Both lanes now share one batch limit of twenty.
The two lanes are kept. They earn their keep in
SyncUploadGate, which holds aseparate rate-limit domain per lane so a backfill cooldown cannot stall a
freshly captured recording. They were not buying throughput control: ordering is
newest-first regardless of lane, and the backend caps multipart part size
(200 MB), not file count — the fresh lane has been sending twenty per batch all
along.
Tests
test_sync_job_stale_self_heal.py— staleprocessingself-heals for inlineand cloud_tasks, a fresh job is untouched, and a stale
queuedjob is neverfinalized.
wal_syncs_firmware_routing_test.dart— the enriched firmware wins over a raw'Unknown', falls back when absent, and a 3.0.20 device now classifies asring.
local_wal_sync_test.dart— a small backlog drains in one batch; larger onesare bounded by the shared limit, newest first.
cd backend && pyteston the sync suites — 193 passed.cd app && bash test.sh— 933 passed.bash scripts/analyze_ratchet.sh— passed.Failure-Class: none