Janitor & Cleanup

Vela cleans up after itself. A background janitor applies retention rules and removes leftovers, and a blob collector deletes content that nothing references anymore — carefully, so that no committed file can ever lose its bytes.

Schedule

JobWhenConfigured by
Janitor pass1 minute after startup, then every intervalVELA_JANITOR_INTERVAL (default 24h, minimum 1m)
Blob collectorEvery 5 minutes inside serve, and as part of each janitor passfixed
Manual passOn demandvelad janitor run

Janitor tasks

Each pass runs these tasks in order. A failing task is logged and does not stop the others.

expired_links

Deletes signed-link records that expired more than VELA_LINK_RETENTION (7 days) ago. Recently expired links stay visible in vela links ls --all for debugging.

expired_objects

Moves objects whose expires_at has passed into the trash. (They were already invisible on the public side.)

trash

Permanently deletes trash entries older than VELA_TRASH_RETENTION (14 days). Their content is queued for the blob collector.

signing_keys

Deletes retired link signing keys that no unexpired link depends on.

web_sessions

Deletes expired, idle and orphaned web sign-in sessions. Sessions are also deleted the moment they are seen expired; this catches the rest. Finds nothing while web sign-in is off.

tmp_files

Removes files in tmp/ older than one hour — remains of uploads interrupted by a crash.

orphan_blobs

Finds blobs older than one hour that no live object or trash entry references and queues them for collection.

blob_gc

Runs the blob collector (below).

multipart_uploadsR2/S3 only

Aborts Vela-managed multipart uploads older than 24 hours. The bucket lifecycle rule covers anything this misses.

Each task logs one structured line with its count and duration (in nanoseconds in JSON logs):

{"time":"2026-10-14T04:00:03Z","level":"INFO","msg":"janitor task done","task":"trash","count":2,"duration":3104511}

The blob collector

Whenever content loses its last reference — a file is overwritten, purged, or found orphaned — the same database transaction queues the blob instead of deleting it. The collector deletes a queued blob only when all of these hold:

  1. the 15-minute grace period has passed, so downloads that were authorized before the change (including ones nginx is serving) can finish;
  2. a full WAL checkpoint has completed — the durability barrier for SQLite's synchronous=NORMAL, so a power loss cannot roll back the database to a state that still references the blob;
  3. a final re-check confirms that no live object or trash entry references it.

Blobs are dequeued only after the physical deletion succeeded. If the backend is unavailable, they stay queued and the next pass retries — no orphan walk needed. While a backup or storage migration holds its lease, nothing is collected at all.

Running a pass manually

$ docker exec vela velad janitor run
TASK             COUNT  DURATION  ERROR
expired_links    0      0s        -
expired_objects  1      2ms       -
trash            2      3ms       -
signing_keys     0      0s        -
web_sessions     0      0s        -
tmp_files        0      0s        -
orphan_blobs     0      12ms      -
blob_gc          0      1ms       -

This is safe while the server is running. Passes are serialized by an in-process mutex and a renewable database lease, so two processes never clean concurrently; if another process holds the lease, the manual pass is skipped. If a long pass loses its lease, it stops rather than continuing in parallel with another.

A manual pass does not shorten retention: trash entries younger than VELA_TRASH_RETENTION stay. To reclaim space immediately, purge explicitly with vela trash purge, then run the janitor — or wait up to five minutes and 15 minutes of grace for the collector.

Where disk space goes

If the data directory grows more than expected, check, in order:

  • The trash: vela trash ls. Deleted files keep their content until retention ends.
  • Overwrites: replaced content is kept for the 15-minute grace period.
  • Expired objects: they move to the trash at the next pass, then wait for retention.
  • Backups stored inside the data directory (hard links share space with live blobs only until those blobs are deleted).
  • Interrupted uploads in tmp/: removed after an hour.