Skip to content

fix: retry a backup that fails on a busy paykit lock - #1552

Merged
ovitrif merged 2 commits into
masterfrom
fix/wallet-backup-retry-busy
Oct 16, 2026
Merged

ovitrif merged 2 commits into
masterfrom
fix/wallet-backup-retry-busy

Conversation

@ovitrif

@ovitrif ovitrif commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #1550

Refs:

This PR retries a backup that fails because the Paykit shared state is busy, instead of leaving it until the next change or app start.

Description

  • Fixes a wallet backup that fails with a temporary Paykit error (shared_state_busy, concurrent_update, a transport error) staying unbacked for the rest of the session. The WALLET snapshot reads Paykit state under its shared-state lock, and a failed backup was only retried once the data changed again or the app restarted. It is now retried after 10 s, doubling up to 5 minutes, which outlasts the lock's write cooldown, while the same required snapshot is still pending.
  • Logs that failure as a retry at WARN instead of Backup failed at ERROR. Other failures keep the current handling and log.
  • Keeps the 30-minute backup failure warning for a backup that stays stuck on temporary errors, and keeps a retry that lands while backup observation is paused, so it runs when observation resumes.

Out of Scope

  • paykit-rs: how long the shared-state lock stays held.

Design

N/A — no UI changes.

Preview

N/A — no user-visible changes.

QA Notes

Journeys

N/A — no user-visible behaviour change.

Manual Tests

N/A

Automated Checks

  • added BackupRepoTest.kt — a wallet backup that fails on a busy Paykit shared state is retried and uploaded without a new change, also across a pause in observation, and still warns once it stays pending past 30 minutes

@ovitrif ovitrif self-assigned this Oct 16, 2026
@ovitrif
ovitrif requested review from a team, ben-kaufman and coreyphillips and removed request for a team October 16, 2026 19:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T19:22:49.105114Z c5b2a11 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects the wallet-backup workflow in the app.

The PR appears safe to merge, with a non-blocking issue in the overdue-backup warning.

Findings

  1. P2 Stuck backups lose their warning ▶

Summary

Adds automatic retries for backups that fail while Paykit is temporarily unavailable.

  • Wallet backups retry after temporary Paykit lock failures.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Backup fails] --> B{Temporary Paykit error?}
    B -->|No| C[Keep existing error handling]
    B -->|Yes| D[Wait with capped backoff]
    D --> E{Still observing and failure matches?}
    E -->|No| F[Stop retry]
    E -->|Yes| G{Backup still eligible?}
    G -->|Yes| H[Schedule backup]
    H --> I[Advance required time]
    I --> J{Upload succeeds?}
    J -->|Yes| K[Clear retry count]
    J -->|No| A
Loading

Reviews (1) · Last reviewed commit: "fix: retry a backup that fails on a busy..." · Reviewed by Greptile

Comment thread app/src/main/java/to/bitkit/repositories/BackupRepo.kt

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5b2a1182e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread app/src/main/java/to/bitkit/repositories/BackupRepo.kt Outdated
Comment thread app/src/main/java/to/bitkit/repositories/BackupRepo.kt
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Regtest APK

Built from 1630e0f (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

@ovitrif

ovitrif commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed 1630e0f, answering the Greptile and Codex findings:

  • The 30-minute backup failure warning now counts from when the temporary failures began, so retries no longer hide a stuck backup.
  • A retry that lands while observation is paused clears its failed marker, so the backup is picked up when observation resumes.
  • BackupRepoTest.kt adds the pause-and-resume case and the warning case.

@talosmachina talosmachina left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings. Retries a WALLET backup that failed on a temporary Paykit error (SharedStateBusy, ConcurrentUpdate, Transport) with a 10 s backoff doubling to 5 min, instead of waiting for the next change or restart. Reviewed 1630e0f, full tier, reasoned from the code and CI (Bitkit Android branches are not built here).

What I checked, and 4 candidates I ruled out

Read in full: BackupRepo.kt (observers, scheduleBackup, triggerBackup, markBackupFailed, checkForFailedBackups, start/stop observing), PaykitExceptionExt.kt, the three new BackupRepoTest.kt cases
Call sites traced: stopObservingBackups (BackupsViewModel, reset() from WipeWalletUseCase.stopNode), markBackupRequired
CI: build (unit tests), lint, detekt green; e2e send and onchain_boost_receive_widgets still running at review time

Ruled out

  • Retry fires after a wipe or a pause: the delayed job checks isObserving after removing the failedBackupRequired marker, so a paused repo drops the retry and the status observer reschedules on startObservingBackups because shouldBackup no longer sees the marker; reset() stops observing before a wipe.
  • Retry races a newer change: failedBackupRequired.remove(category, backupRequired) only matches the exact failed required value, and markBackupRequired clears the marker first, so a newer change schedules through the observer and the stale retry is a no-op.
  • 30-minute warning suppressed by retries: checkForFailedBackups takes the earlier of temporaryFailureSince and status.required, so repeated retries bumping required do not reset the window; covered by the new stays pending past the failure window test.
  • Shift overflow: the doubling is capped at MAX_RETRY_SHIFT = 6 and coerced to 5 min, so the attempt counter growing does not overflow the delay.

Merge confidence: 4/5, the change is covered by BackupRepoTest.kt but two e2e jobs were still running when I read it.

@ben-kaufman ben-kaufman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1630e0f. The retry, warning-age, and paused-observation fixes look good, with no blocking findings. All 72 BackupRepo tests pass. I inspected the complete Detekt report: its 78 findings in changed files map to unchanged base code, with no introduced finding identified. Current hosted checks are green.

@ovitrif
ovitrif merged commit 722c824 into master Oct 16, 2026
21 checks passed
@ovitrif
ovitrif deleted the fix/wallet-backup-retry-busy branch October 16, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: a wallet backup that hits a busy paykit lock is not retried until the next change

3 participants