Skip to content

Improve checkpointing for background sync #13909

@Okuro3499

Description

@Okuro3499

Problem

After a full sync completes, five large tables — ratings, courses_progress, submissions, login_activities, and team_activities — are synced via a background coroutine which processes each sequentially by paginated batches (with copyToRealmOrUpdate).

There are two key failure modes:

  1. No checkpoint persistence

    • Pagination skip offset (tracking sync progress) is only held in memory.
    • If the app is killed, force-stopped, or OOMs mid-way, or if network is lost, the next sync starts from skip=0 for the affected table.
    • On large installs, this can require re-downloading tens of thousands of rows on every interruption.
  2. No per-session progress on network loss

    • If network goes down during background sync, the current offset is discarded.
    • On restoration, the user must trigger a new full sync from scratch.
    • Worse, in some cases (e.g. HTTP 503 from the server), code paths delete any partial progress, so even transient errors erase checkpoints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions