Skip to content

Cancellation can leave diary records cached after local sign-out #763

Closed

Description

@lumenpearson

Failure scenario

DiaryRepositoryImpl performs store.forgetDiary() and forgetLocal() as separate suspending operations. Cancellation after the credential commit but before cache cleanup leaves the phone signed out while the previous account's rows remain on disk. The broad runCatching around api.logout() also swallows a transport-thrown CancellationException in an otherwise active context and can continue to a successful local sign-out.

Source a86f0ce: DiaryRepositoryImpl.kt108/114 and DiaryRepository.kt51. This ordering predates 5b but is explicitly in the approved cancellation/sign-out review focus. The independent review and source trace identify it; No new behavioral regression had run at filing.

Acceptance

  • A remote CancellationException propagates with credentials/cache unchanged.
  • Cancellation immediately after the first owned local credential commit cannot strand populated cache tables; cleanup finishes and cancellation still reaches the caller.
  • An ordinary network failure remains best effort; first persistence failure retains its distinct behavior.
  • A concurrent successor account is protected by the same local transition ownership.
  • Deterministic RED/GREEN, complete affected gates/counts and dev/master delivery pass with Move the remaining Android remotes to v2 transports (stage 5b) #746.

Parent #746; review finding I5, single corrective pass. Synthetic accounts and local storage only.

Corrective checkpoint — 14 November 2026

DiaryAccountTransitionTest observed swallowed remote cancellation, stranded rows after credential commit and successor erasure before correction.

Remote CancellationException now propagates before mutation; once an owned credential commit starts, local cache cleanup finishes despite cancellation. Ordinary offline logout, first disk refusal and successor controls pass; all eight transition/control cases pass.

The ONE review corrective cohort first produced82 cases/20 AssertionError failures; the same82 identities now pass. Full unfiltered Android test/both ordinary assembles/detekt passed at2202 unique cases,0failures/errors/skips. Both completed-report count validators pass at3910/2202 and168 selected document guards pass separately. No baseline growth or suppression was added. Earlier failed/green evidence remains retained.

Corrective head is 473e88af87b5a106cee660a2c7fe24b7029fd0f9 in draft PR #757. Exact-head CI43554034696 is still running at this checkpoint. CI/dev/master delivery and the broader #746 acceptance remain unfinished; this issue stays open. No re-review is planned; Minor #764/#765 remain deferred.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions