Skip to main content

Module retention

Module retention 

Source
Expand description

Data retention: which vault blobs the database still refers to, the removal of blobs nothing refers to (teamcraft vault gc, and the blobs of expired staged imports and upload sessions) and the trimming of the preview cache, and the removal of superseded versions of latest files (purge_superseded_versions). The audit log retention is audit::purge_older_than.

Referenced content is never removed. A blob is removed only when no column of BLOB_COLUMNS names it and it was not written or stored again within a grace period: the vault renews a blob’s modification time whenever the same content is stored again (vault.rs), and every writer stores the blob before it inserts the row that refers to it, so content on its way into the database is always younger than the grace period. The time is checked again right before the removal. A store of identical content that overlaps the removal itself re-checks that the blob exists after renewing it and puts its own copy in place otherwise; the remaining window is a few instructions wide and only open for blobs that were idle for the whole grace period.

Structs§

GcReport
Outcome of collect_garbage.
Orphan
An unreferenced blob found by collect_garbage.
PreviewPurge
Outcome of purge_previews.
PurgedFile
The superseded versions of one file that purge_superseded_versions removed (or, in a dry run, would remove).
VersionPurge
Outcome of purge_superseded_versions.

Enums§

Release
What release_blob did.

Constants§

BLOB_COLUMNS
Every column that may name a vault blob by its SHA-256 – the files and their versions, change request attachments, staged STEP imports and upload sessions (the stored content, and the hashes the client announced or started from). shape_signatures.sha256 is derived data and branding_logos.sha256 the hash of bytes kept in the row; neither keeps a blob alive. A test checks this list against the migrations.
DEFAULT_GC_GRACE_HOURS
Default grace period of teamcraft vault gc.
DEFAULT_LATEST_GRACE_DAYS
Default grace period before a superseded version of a latest file is removed (TEAMCRAFT_RETENTION_LATEST_GRACE_DAYS).
IN_FLIGHT_GRACE
Grace period of the housekeeping: blobs of expired staged imports and upload sessions written or stored again within the last hour stay (and the staged import with them, until the next run).
MAX_LATEST_GRACE_DAYS
Longest grace period accepted (ten years).
NOT_BLOB_COLUMNS
Hash columns that are not references to vault content.

Functions§

collect_garbage
teamcraft vault gc: walks the vault one objects/ab/ directory at a time and finds the blobs no column of BLOB_COLUMNS names and that were not written or stored again within grace. Only with apply are they removed (each after a last check of its time).
purge_previews
Trims the preview cache (<vault>/previews): removes the previews and thumbnails of blobs the database no longer refers to, files of older cache versions and temporary files older than an hour; then, with max_bytes > 0, the least recently used files until the cache fits. Files with other names are left alone. Everything removed is made again when it is needed.
purge_superseded_versions
Removes the old versions of files whose retention is latest: a version goes when a newer version replaced it at least grace_days ago (the time of the next version’s upload counts, so a rollback or a mistaken upload can still be undone within the grace period). The blobs nothing refers to afterwards are removed from the vault. Without apply it only reports.
referenced
The hashes of hashes that a column of BLOB_COLUMNS names.
release_blob
Removes one blob if nothing in the database refers to it – as seen by conn, so a caller can delete the last referring row in the same transaction first – and it is older than grace.