Skip to content

platform-wallet: a cancelled sync worker can run one more pass after Clear/reset completes #6290

Backlog

Description

@llbartekll

Problem

A background sync worker that has already passed its cancellation check can still run one full pass after a reset (Clear) has finished.

For platform-address sync this means: a user clears platform-address data, Clear reports success and that sync is stopped, and the cancelled worker then writes a fresh balance snapshot and sync watermark back.

How it happens

The coordinator loop checks cancel.is_cancelled() and then calls the pass. The pass takes the sync slot and checks the admission gate, but does not look at the loop's cancellation token again.

  1. The worker passes cancel.is_cancelled() and is descheduled before it claims the sync slot.
  2. reset_platform_address_sync_state closes admission, cancels the worker, sees an idle slot, resets the wallets, and reopens admission when its guard drops.
  3. The worker resumes, enters through the reopened gate, and runs a pass.

The window is two adjacent statements, so this needs an unlucky preemption, but nothing rules it out.

Scope

Proposed fix

After #6163 this is one place instead of five: re-check the loop's cancellation token after admission (once the slot is held) in SyncLoop, and skip the pass if it is cancelled. Add a test that parks the worker between the check and admission, runs the reset, and asserts no pass runs afterwards.

Related, same loop

A tick refused because an old pass still holds the slot can be followed by a full-interval sleep instead of the short retry, if that old pass drains before the loop samples the latch. Also unchanged from the old loops; raised in #6163 (comment). Can be fixed together, with a test seam that lets the retry-cadence test observe which delay the worker chose.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions