Skip to content

Background jobs

Understanding the maintenance work running behind the scenes — compaction, indexing, and garbage collection.

As a namespace accumulates writes, maintenance work keeps metadata reads indexed and efficient, updates derived indexes, and deletes expired resources. Maintenance runners schedule jobs and each job reads from durable state and performs an isolated unit of work, off the hot-commit/WAL path.

The reference server schedules maintenance for active namespaces and runs periodic store-wide sweeps for idle namespaces and pools. Embedded deployments must schedule maintenance explicitly; a one-off CLI command does not leave a maintenance process running.

Metadata maintenance folds the visible WAL tail into immutable metadata segments and compacts those segments in bounded units. The reference implementation requests a fold at 8 MiB of unfolded WAL bytes or 256 unfolded WAL objects. At 64 MiB or 1,024 objects, new commits wait for a fold and can return maintenance_required if that wait exceeds 30 seconds. These are reference defaults, not storage-format limits.

Use loonfs maintenance metadata to start a single pass or loonfs maintenance fold to flush the current WAL tail regardless of its length.

Indexing is another background job type that can be used to answer queries outside the scope of the core metadata tables. For example, one native index in LoonFS is the content index behind the grep-like Search capability.

Native LoonFS indexes can be complemented with external indexes. In many cases, Checkpoints and the Changefeed may be a more natural API for building non-native indexes.

LoonFS uses append-only immutable objects and tombstone soft-deletion. Garbage collection later does mark-and-sweep passes over objects that are no longer reachable, and respects checkpoints, forks, upload receipts, and GC safety grace windows.

Namespace collection reclaims metadata; pool collection separately reclaims shared content, upload records, and temporary objects. The reference server includes pools in its store-wide sweeps. Manually scheduled maintenance must cover both kinds of collection. See Data lifecycle for how retention makes data eligible for cleanup.