Skip to content

Rework garbage collection to keep repo directory #190

Description

@geek-merlin

Problem

In #172, it was discovered that the changing repo dir name causes several problems.

Refs

GC was updated in #32 #75 #132

Currrent situation,

Let's first state the current situation and how it evolved, as reality check.

GC checks for every chunk, if it has a direct or indicŕect reference from a name, and only keeps the referenced.
There are sophisticated ways to do that without locking, so backup and GC can safely act at the same time, but for the sake of simplicity, we are using a suitable form of locking (creating a lock file in the repo). (But note that #188 might benefit from no locks.)

Some time ago, the GC reference checks had been done in a memory based Key-Value store (in fact we only need the keys), but this soon gets huge and does not scale.
So in #132, this was changed to a method where chunk files were moved when a reference was seen, so the repositlry itself is used as a key-value-store.

While this has scalability wins, it also brings us some drawbacks:

  • While content-addressable syncers (that use hashing to spot file renames) can spot the rename and do a cheap rename on the target, other syncers have to effectively copy the whole repository. :-/
  • On cloud storage, name changes may be costly, and at least are, if a syncer deletes and re-uploades lots of files.
  • Using remote cloud storage as KV store is bound to be extremely slow (compared to identifying files to delete locally and then deleting them).

Proposal

Let's combine the best of both approaches and use a scalable KV store like this:

GC service:

  • lock the repo by adding a suitable file.
  • read all chunk ids and add them to the trashlist
  • iterate recursively over chunk ids referenced from names, and remove them from trashlist
  • when done, delete all chunks left on trashlist
  • unlock the repo

The trashlist service can be any scalable (non-memory-only) KV store (we only use keys, and leave value empty).
Let's e.g. start wigh the caves crate and its local file backend, and evaluate its rocksdb backend and maybe other options in a followup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions