Skip to content

Purge order by read #324

Description

@Rekseto

Purge in read order

Goal

objects.purge iterates oldest-read to newest-read. Selection order only — holders stay independent. If the pass is interrupted, the coldest objects are already handled.

Approach

Add read_at to dbObject. Track reads in memory; flush opportunistically (timer, shutdown, cache pressure, or piggybacked on purge). No per-read DB writes.

Bump at the Module, on the returned Reader, once per logical read, on successful close with bytes delivered. Identity is per object ID.

Qualified reads

Counts: user reads, peer-served reads, Load from external callers.

Skips: Probe, GetType, Contains, Scan, Free, RepoGroup race losers, seek-reopens, failed/cancelled reads.

Rejected alternatives

  • Per-read DB write — write amplification on hot read paths.
  • In-memory only — no persistence; read history is lost on every restart.
  • Dedicated reads table — extra schema for no gain once flushing is in place.
  • Filesystem atime — unreliable in practice and doesn't cover memory or network repos.

Open questions

  • Flush triggers — which combination.
  • Unknown read_at semantics: eligible vs skip; fallback to CreatedAt.
  • dbObject is sparse and repo-agnostic — backfill on first scan, or add a repo column.

Follow-up

  • --not-read <duration> filter on top of the order, once tracking lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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