Skip to content

Migrate IpfsPinningService's pin registry off in-memory storage #189

Description

@balisdev

Owner: whoever owns IPFS/storage (unassigned) · Priority: Medium — does not block rollout of the Redis approach elsewhere, but the raw-content sub-decision below should land before this migrates, not after.

Description

IpfsPinningService (src/ipfs-pinning/ipfs-pinning.service.ts) keeps two process-local stores: Map<cid, PinRecord> (pin metadata/status, read by RepinWorkerService to find under-replicated pins) and Map<cid, Buffer> (the original uploaded bytes, retained so a re-pin retry doesn't need the original caller to re-upload). Follow-up from the persistence spike (#181) — see backend/PERSISTENT_STORAGE_SPIKE.md (§2, §7).

These two stores don't have the same shape and shouldn't be migrated the same way:

  • PinRecord metadata is a good Redis fit — small JSON per CID, point lookups, filter by replication status. Same pattern as GigService (Spike: Persistent, multi-instance-safe storage strategy to replace in-memory service state #181): SET pin:{cid} <json>, plus a set/sorted-set index for "needs re-pin" queries RepinWorkerService runs.
  • Raw content Buffers are a poor fit for Redis as general-purpose KV storage — binary blobs bloat Redis memory fast, and this isn't what Redis is for. Needs its own decision: either move raw content to object storage (S3-compatible) with only a reference stored alongside the pin metadata, or drop the retry-without-refetch behavior and require the caller to resupply content on a failed re-pin. Get a rough per-record size × expected volume estimate before committing either way (see the spike's §7 sizing note).

Tasks

Acceptance Criteria

  • Pin metadata survives a process restart
  • Multiple backend instances observe the same pin state
  • A decision on raw-content storage is documented, with a follow-up filed if it needs its own implementation work
  • Existing ipfs-pinning.service.spec.ts / repin-worker.service.spec.ts tests still pass, updated for the new store

Estimated Time

2-3 days

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