Skip to content

sync: the status refresh reads every answered push and agreed row on each cycle #209

Closed

Description

@frostyard-machines

(*loop).refreshStatus (internal/syncer/loop.go:1320-1380) runs at the end of every sync cycle (loop.go:365), also an idle one. To fill 3 numbers of sync.status it reads whole tables:

  • db.Pending (internal/store/remotes.go:336) and db.PendingConflicts (:508): every pending change, with correlated subqueries over sync_pushes, only to take len(...).
  • db.Unanswered (remotes.go:412): every unanswered push, to count the conflict pushes.
  • db.AgreedRows (remotes.go:311): every agreed row of the vault, to count the conflicted ones.
  • refusals (loop.go:1383-1410): db.Pushes returns every answered push the device ever made (remotes.go:418, localPushes with no limit), builds a map of the newest push per file, then runs db.FileByID for each refused one.

No code deletes rows from sync_pushes (grep -n sync_pushes internal/store/*.go finds only INSERT and UPDATE), so the refusals scan grows with every push for the life of the vault, and it runs on every cycle.

What's wanted: the counts from COUNT(*) queries (or 1 query that returns the 3 counts), and the refusals from a query that selects only the newest push per file whose status is refused. Whether sync_pushes should drop answered rows that a newer push of the same file supersedes is a retention question for docs/specs/sync-protocol.md; it is not needed for the first part.

Found in a code review of main at b9c6c90.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions