Skip to content

Data lifecycle

How retention, snapshots, namespace deletion, and garbage collection control what stays readable and when storage is reclaimed.

This page explains what happens to files, snapshots, and namespaces after you delete them, and how retention and garbage collection reclaim space in object storage.

In LoonFS, deleting a file, expiring a snapshot, or deleting a namespace doesn’t remove objects from object storage immediately. Retention controls how much history stays readable, compaction removes metadata that is no longer needed, and garbage collection deletes unreferenced objects after a grace period.

Uploading a file writes its bytes into the namespace’s pool, but completing an upload doesn’t automatically create or update a file in the namespace. The file appears in the filesystem only after a commit publishes that content reference.

While an upload session is open or recently completed, its upload record protects the staged bytes from pool garbage collection (even if no commit ever publishes those bytes). Abandoned or unused uploads become eligible for deletion only after the session record expires and is collected.

Keeping every historical revision and deleted item indefinitely would make namespace metadata grow without bound. To bound that growth, every namespace has a retention floor (retention_floor_seq), which is the oldest commit sequence that LoonFS keeps intact.

During compaction, each visible file keeps every revision above the retention floor plus its newest revision at or below the floor, and older revisions can be dropped. For example, if a file has revisions at sequences 10, 25, and 50, and the retention floor moves to 30, compaction keeps revision 25 (the newest revision at or below 30) and revision 50, and can drop revision 10.

To advance the retention floor automatically over time, set retention_window_ms when creating a namespace or update it later through maintenance. Forks inherit their parent’s window. If no window is configured, the reference server doesn’t advance the floor during scheduled sweeps, though an operator can still advance the floor manually.

LoonFS uses a 24-hour garbage-collection grace period, so retention_window_ms must be at least 24 hours (86,400,000 ms). The retention floor never moves backward, and raising the window later doesn’t restore history that compaction already removed.

Advancing the retention floor also drops old changefeed events, commit retry receipts, and the merge history needed by open forks. Set retention_window_ms longer than your longest changefeed consumer outage or open fork. Creating a snapshot protects the view captured by that snapshot, but it doesn’t stop the live namespace’s retention floor from advancing.

Deleting a file or directory removes its name from its parent directory and writes a deletion record (a “tombstone”) in the trash. As long as the deletion sequence (deletion_seq) is above retention_floor_seq, you can restore the item and its subtree from the trash using its inode ID and deletion sequence.

Once the retention floor reaches deletion_seq, the deletion expires, so the item disappears from the trash and a restore returns not_deleted. Compaction can then remove the hidden metadata, and pool garbage collection can delete the file bytes once no other namespace, snapshot, or upload record references those bytes.

Restoring an earlier version of an existing file is a separate operation (it creates a new current revision from the file’s revision history). See Revisions.

Snapshots and forks protect specific views from compaction and garbage collection even after the live namespace moves on:

Snapshot typeWhat it protectsWhen it is released
User snapshotThe captured namespace view and every content object that view references.Deleting the snapshot or letting its TTL expire makes the snapshot unreadable, and garbage collection removes the record after the 24-hour grace period.
Fork snapshot (on parent)The parent metadata segments inherited by the fork.When the fork is retired.
Fork point snapshot (on fork)The fork’s starting view, used for historical reads and rebases.When the fork is retired.

A user snapshot created without a TTL stays readable until you delete the snapshot. Merging a fork doesn’t release its fork snapshots, so delete finished forks once you verify the merge.

Calling Delete namespace records a deleted state on the namespace rather than removing every object in object storage synchronously.

After the 24-hour grace period, namespace garbage collection retires the namespace once no snapshot (other than the namespace’s own fork point snapshot) still depends on the namespace. Because a child fork depends on metadata segments from its parent, a chain of deleted forks retires from the newest child back up to the parent.

When LoonFS retires a namespace, it releases the namespace’s fork snapshots, removes the namespace from its pool’s member list, and updates the namespace boundary (boundary.json) to retired so that namespace ID can’t be reused. Later garbage collection runs delete the remaining metadata while keeping the boundary record that prevents stale writers from reviving the namespace. Namespace retirement never deletes shared file bytes directly, because pool garbage collection checks whether any other member still references those bytes.

The reference server runs maintenance automatically for active namespaces and runs periodic store-wide sweeps across idle, deleted, and retired namespaces, shared pools, and configured retention windows.

If you schedule maintenance yourself, run both namespace garbage collection and pool garbage collection on a schedule. Cleanup often takes multiple passes because one pass can remove an expired snapshot or upload record, making its referenced objects eligible for deletion on a later pass. Keep running maintenance on a schedule even after a pass deletes nothing.

There is no guaranteed time by which deleted bytes leave object storage, because remaining references, the 24-hour grace period, maintenance cadence, and your bucket’s own object-versioning or retention rules all affect when objects are deleted. See Background jobs.