fix(android): backup retry stuck in 2h backoff lockout - press forces retry, cap ends honest failure #1408

Merged
chris merged 1 commit from fix/backup-retry-backoff into main 2026-10-26 14:48:29 +01:00
Owner

Device-verified problem (Pixel 2, adb)

After repeated upload 502s (server-side proxy hop, tracked separately as ISSUE-213), the one-off BackupWorker sat deep in WorkManager exponential backoff: attempt 9 → next run in +2h08m (JobScheduler dump: Minimum latency: +2h7m59s). During that whole window:

  • the primary button showed „Sichert …" and was disabled, and
  • BackupScheduler.enqueueNow early-returned on the merely ENQUEUED request,

so the user could not force a retry and the Sicherung tab looked hung for two hours.

Fix

  • enqueueNow guard skips only on RUNNING: ENQUEUED/BLOCKED proceed with the REPLACE enqueue — cancelling a non-running request is safe, starts a fresh attempt immediately and resets the backoff. Manual press during backoff = force retry now.
  • One-off request gets LINEAR 30s backoff so retries stay frequent until the cap.
  • BackupWorker retry cap (MAX_AUTO_RETRIES = 5, single retryOrFail funnel for all three retry sites): after the cap the run FAILS with the error marker — the last-run card shows the honest „Fehlgeschlagen" + cause instead of an endless backoff wait. Auth-expired handling untouched.
  • BackupStatusViewModel: new isRunInProgress gate (RUNNING only, either lane) drives button enable/label and the backupNow()/retryFailed() guards; isWorkActive keeps the wider ISSUE-208 semantics; the terminal-refresh now fires when a run ends, not when queue states flip.

Verification

  • 5 new JVM state-table tests (shouldSkipImmediateEnqueue, shouldFailInsteadOfRetry) + rewritten VM gating tests (one-off ENQUEUED now pressable with normal label; RUNNING disabled „Sichert …"; periodic ENQUEUED unchanged)
  • Full module forced rerun: 871 tests, 0 failed
  • versionName 0.10.18 + changelog; KNOWN_ISSUES: ISSUE-212 (resolved) + two new open findings from today's debugging: ISSUE-213 (web-proxy 500/502 TypeError: fetch failed on multi-100MB uploads) and ISSUE-214 (worker_jobs retention DELETE violates discovery_results_worker_job_id_fkey, recurring ERROR in API logs)
## Device-verified problem (Pixel 2, adb) After repeated upload 502s (server-side proxy hop, tracked separately as ISSUE-213), the one-off BackupWorker sat deep in **WorkManager exponential backoff**: attempt 9 → next run in **+2h08m** (JobScheduler dump: `Minimum latency: +2h7m59s`). During that whole window: - the primary button showed **„Sichert …"** and was disabled, and - `BackupScheduler.enqueueNow` early-returned on the merely **ENQUEUED** request, so the user could not force a retry and the Sicherung tab looked hung for two hours. ## Fix - **enqueueNow guard skips only on RUNNING**: ENQUEUED/BLOCKED proceed with the REPLACE enqueue — cancelling a *non-running* request is safe, starts a fresh attempt immediately and **resets the backoff**. Manual press during backoff = force retry now. - **One-off request gets LINEAR 30s backoff** so retries stay frequent until the cap. - **BackupWorker retry cap** (`MAX_AUTO_RETRIES = 5`, single `retryOrFail` funnel for all three retry sites): after the cap the run **FAILS with the error marker** — the last-run card shows the honest „Fehlgeschlagen" + cause instead of an endless backoff wait. Auth-expired handling untouched. - **BackupStatusViewModel**: new `isRunInProgress` gate (RUNNING only, either lane) drives button enable/label and the `backupNow()`/`retryFailed()` guards; `isWorkActive` keeps the wider ISSUE-208 semantics; the terminal-refresh now fires when a *run* ends, not when queue states flip. ## Verification - 5 new JVM state-table tests (`shouldSkipImmediateEnqueue`, `shouldFailInsteadOfRetry`) + rewritten VM gating tests (one-off ENQUEUED now pressable with normal label; RUNNING disabled „Sichert …"; periodic ENQUEUED unchanged) - Full module forced rerun: **871 tests, 0 failed** - versionName 0.10.18 + changelog; KNOWN_ISSUES: ISSUE-212 (resolved) + two new open findings from today's debugging: ISSUE-213 (web-proxy 500/502 `TypeError: fetch failed` on multi-100MB uploads) and ISSUE-214 (worker_jobs retention DELETE violates `discovery_results_worker_job_id_fkey`, recurring ERROR in API logs)
fix(android): backup retry stuck in 2h backoff lockout - press forces retry, cap ends honest failure
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 3s
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build Android CI image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Deploy review instance (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 4s
Build and Deploy / Android unit tests and debug APK (push) Successful in 3m53s
7be9508f9e
Device-verified (Pixel 2): after repeated 502s the one-off BackupWorker sat in
WorkManager exponential backoff (attempt 9, next run +2h08m) while the primary
button stayed disabled on "Sichert ..." and enqueueNow refused to replace the
merely queued request - the user could not force a retry and the tab looked
hung for two hours.

- enqueueNow guard skips only on RUNNING; ENQUEUED/BLOCKED now proceed with
  the REPLACE enqueue (fresh attempt now, backoff reset); one-off request gets
  LINEAR 30s backoff so retries stay frequent until the cap
- BackupWorker retry funnel: after MAX_AUTO_RETRIES (5) the run FAILS with the
  error marker instead of retrying forever - the last-run card shows the
  honest failure with the cause
- BackupStatusViewModel: new isRunInProgress gate (RUNNING only) drives the
  button/retry; isWorkActive keeps the wider ISSUE-208 semantics; terminal
  refresh now fires when a RUN ends, not when queue states flip
- tests: 5 new scheduler/worker state-table cases + rewritten VM gating tests,
  871 green
- versionName 0.10.18 + changelog; KNOWN_ISSUES ISSUE-212 (resolved) plus
  open ISSUE-213 (web-proxy 500/502 on multi-100MB uploads) and ISSUE-214
  (worker_jobs retention DELETE FK violation)
chris merged commit f5ae399f4c into main 2026-10-26 14:48:29 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!1408
No description provided.