From c1f8d75019801aaa72827cde6cd78ac32aadeec3 Mon Sep 17 00:00:00 2001 From: Lain Soykaf Date: Wed, 2 Sep 2026 11:53:42 +0400 Subject: [PATCH] docs: document the bounded retention mode --- changelog.d/retention-mode.add | 1 + docs/administration/CLI_tasks/database.md | 3 +++ docs/configuration/cheatsheet.md | 17 +++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 changelog.d/retention-mode.add diff --git a/changelog.d/retention-mode.add b/changelog.d/retention-mode.add new file mode 100644 index 000000000..0d175a7c1 --- /dev/null +++ b/changelog.d/retention-mode.add @@ -0,0 +1 @@ +Add a bounded retention mode (`config :pleroma, :retention`): a cron worker continuously evicts old remote threads nobody local interacted with, in small batches, so the database plateaus instead of growing forever. `prune_objects --keep-threads` now also keeps threads that mention a local user or contain a reported post. diff --git a/docs/administration/CLI_tasks/database.md b/docs/administration/CLI_tasks/database.md index c5e51e555..c8d569f39 100644 --- a/docs/administration/CLI_tasks/database.md +++ b/docs/administration/CLI_tasks/database.md @@ -28,6 +28,9 @@ Replaces embedded objects with references to them in the `objects` table. Only n This will prune remote posts older than 90 days (configurable with [`config :pleroma, :instance, remote_post_retention_days`](../../configuration/cheatsheet.md#instance)) from the database. Pruned posts may be refetched in some cases. +!!! tip + To keep the database bounded continuously instead of pruning in one go, see [`:retention`](../../configuration/cheatsheet.md#retention). It uses the same rules as `--keep-threads` but runs in small batches from a cron worker. + !!! note The disk space will only be reclaimed after a proper vacuum. By default Postgresql does this for you on a regular basis, but if your instance has been running for a long time and there are many rows deleted, it may be advantageous to use `VACUUM FULL` (e.g. by using the `--vacuum` option). diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md index 0275d2be0..f8a48ade1 100644 --- a/docs/configuration/cheatsheet.md +++ b/docs/configuration/cheatsheet.md @@ -1185,6 +1185,23 @@ Control favicons for instances. * `enabled`: Allow/disallow displaying and getting instances favicons +## :retention + +Bounded retention of remote content. Local posts are your data; remote posts are a cache of somebody else's, and this treats them that way. When enabled, a cron worker (`Pleroma.Workers.Cron.RetentionWorker`, hourly by default) evicts a batch of remote threads that nobody local has interacted with and that have been quiet for longer than `remote_post_retention_days` (see [`:instance`](#instance)). The database then plateaus instead of growing without limit. + +A thread is never evicted if it contains a local post, reply, favourite, repeat or reaction, a post bookmarked by a local user, a post that mentioned a local user (as long as the notification has not been cleared), or a post that was reported. Relationship activities (follows, blocks) and chat messages are never touched. Evicted posts are refetched on demand when somebody opens them again, as with `prune_objects`. + +!!! warning + A local quote post does not pin the post it quotes, since quotes do not share the quoted thread's context. Old quoted remote posts can be evicted and will be refetched when the quote is viewed. + +* `enabled`: Run the worker. Defaults to `false`. +* `max_objects`: Optional watermark. When the `objects` table is estimated to hold more rows than this, the oldest unpinned remote threads are evicted regardless of age. Defaults to `nil` (age only). +* `batch_size`: Maximum number of threads evicted per run. Defaults to `500`. +* `keep_non_public`: Also keep threads that contain a non-public post. Defaults to `false`. + +!!! note + Each run scans the `activities` table once to find quiet threads. On a very large database consider running the worker less often by overriding its `crontab` entry (see [`Oban`](#oban)). To make the initial cut on an instance that has been running unbounded for a long time, run `prune_objects --keep-threads --prune-orphaned-activities` once and let the worker keep it bounded from there. Space freed by eviction is reused by new rows; it is not handed back to the filesystem unless you `VACUUM FULL`. + ## Pleroma.User.Backup !!! note