Repository navigation
fix(sync): stop reconcile polling loop on rate limit and clear uploaded wals on delete pending (#21279) - #21387
Merged
kodjima33 merged 6 commits intoOct 13, 2026
Conversation
…ed wals on delete pending (BasedHardware#21279)
…ed wals on delete pending (BasedHardware#21279)
…ed wals on delete pending (BasedHardware#21279)
kodjima33
approved these changes
Oct 13, 2026
kodjima33
left a comment
Collaborator
There was a problem hiding this comment.
Confirmed root cause (break statement didn't stop the outer poll loop or install the rate-limit cooldown) and confirmed still present on main; small scoped fix (17 lines), closes real issue #21279, mirrors existing SyncRateLimiter pattern.
This was referenced Oct 16, 2026
aryanorastar
added a commit
that referenced
this pull request
Oct 16, 2026
…io (#21829) ## What changed and why Bound a ring-buffer download that becomes silent after READ_BEGIN or DATA. The initial five-second timeout was cancelled on BEGIN, leaving only a 30-minute overall deadline. A connected, stalled read therefore kept the transfer owner busy instead of yielding to normal capture/retry orchestration. - Reset a 15-second idle deadline on the first valid BEGIN and nonempty DATA, matching the existing legacy SD idle bound. Repeated BEGIN, empty DATA and control chatter are not progress. - Observe arrival before queued custody/disk work. On timeout, stop admitting notifications, send STOP on the original connection epoch, drain already received bytes and flush complete records through the existing durable WAL owner. Do not acknowledge an unfinished source or advance an unproven frontier. - Cancel idle timers on completion/error and put read-command failures through the same cleanup. A valid DONE arrival cancels the radio idle deadline even while its validation waits behind custody I/O. Healthy DONE and existing custody capability gates remain. - Make the ring custody fixtures wait for read/status admission rather than fixed startup sleeps, keeping the original durable-advance assertions. - Preserve the saved cause, original stack and phase when a read-command failure goes through cleanup; keep catch-and-continue behavior. Related: #21279 (uploaded jobs queued/429), #21387 (merged polling backoff), #21319 (merged short-WAL batching), #21755 (merged backfill dispatcher-owner repair), #21823 (merged batch-worker quarantine), and #21362 (retained-upload recovery). These are separate stages. This PR does not close the customer case or assert that the reported 1.4 KB/s, capture interruption, cloud worker state or missing recaps share this cause. No firmware version or diagnostic export was supplied for the Discord 0/127 report, and no production repair, storage deletion or deployment is performed. Why isn't this a shared primitive instead? The existing ring reader already owns read admission, STOP, notification ordering, durable flush and frontier validation. Its watchdog belongs inside that owner, not in a parallel recovery actor. The injectable timer tests the real owner without waiting 15 seconds. ## Product invariants affected - INV-CAP-1 — complete received records still use existing durable file/index registration. Timeout leaves the source pending and sends no unproven advance. Legacy firmware may reclaim on BLE delivery before app durability; this does not repair or conceal that existing risk or promise recovery of incomplete records. ## Verification - Production ring-owner regression: 14 tests passed, including idle BEGIN, partial audio, ignored chatter, cancelled deadlines, healthy DONE and bytes queued behind a deliberately blocked custody check, with and without DONE. - Capture interruption/reconnect journey (`mobile-verify fast --paths app/lib/services/wals/ring_storage_sync.dart`): 3 checks passed, no skips. - Full app analyzer ratchet: passed. `make preflight`: 25 checks passed. - Broader ring/custody/capture regression suites: all 129 passed on the final code, including the diagnostic guard and the 14 ring-owner tests above. - Diagnostic guard: confirmed red without the transfer failure's saved error, then green with its original stack, cause and phase preserved. Changed-file analyzer: no issues found. - Physical BLE throughput, microphone behavior, customer-account processing and released-app retest: not performed; require hardware/account evidence. Architecture and implementation/release checklist: `app/docs/offline-sync-stall-recovery.md`. The listen/pusher pipeline map is updated. This needs a mobile release after merge, not a backend deployment. ## UI evidence UI-Evidence: none -- transfer lifecycle only; no UI, copy or layout changes ## Failure class Failure-Class: FC-sync-failure-records-drop-cause
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 of Changes
SyncRateLimiter.instance.markLimitedwhenfetch.outcome == SyncJobFetchOutcome.throttled.if (SyncRateLimiter.instance.isLimited) break;), preventing runaway sequential polling over backlogs of thousands of jobs.deleteAllPendingWals()to includeWalStatus.uploadeditems wheresyncedAt == 0, allowing users to discard stale "Uploaded · processing on Omi" jobs via Manage Storage → Delete Pending.Root Cause / Technical Context
_reconcileUploadedWals(), when a 429 was returned,case SyncJobFetchOutcome.throttledonly executed abreakwithin the switch statement without breaking the outerfor (var i = 0; i < entries.length; i += maxConcurrent)loop. As a result, when large queues of jobs were present, the client continued hammering the server sequentially for all entries, generating thousands of 429s.deleteAllPendingWals(), onlyWalStatus.missitems were collected, offering no client-side recovery to clear stuck server jobs (WalStatus.uploaded).Verification & Testing
app/lib/services/wals/local_wal_sync.dart.SyncRateLimitersemantics and cooldown reasons.Product invariants affected
Line-Count-Exception: app/lib/services/wals/local_wal_sync.dart | 2641 -> 2651 | Add SyncRateLimiter 429 backoff handling and stuck uploaded wal clearing on delete pending
UI-Evidence: none -- Non-UI background WAL synchronization rate limiter fix and storage cleanup
Failure-Class: none
Closes #21279.