Also prune removes and undos
This commit is contained in:
parent
e747f164d4
commit
4d1a18537e
3 changed files with 44 additions and 0 deletions
|
@ -159,3 +159,23 @@ Change `default_text_search_config` for database and (if necessary) text_search_
|
|||
```
|
||||
|
||||
See [PostgreSQL documentation](https://www.postgresql.org/docs/current/textsearch-configuration.html) and `docs/configuration/howto_search_cjk.md` for more detail.
|
||||
|
||||
## Pruning old activities
|
||||
|
||||
Over time, transient `Delete` activities and `Tombstone` objects
|
||||
can accumulate in your database, inflating its size. This is not ideal.
|
||||
There is a periodic task to prune these transient objects,
|
||||
but on first run this may take a while on older instances to catch up
|
||||
to the current day.
|
||||
|
||||
=== "OTP"
|
||||
|
||||
```sh
|
||||
./bin/pleroma_ctl database prune_task
|
||||
```
|
||||
|
||||
=== "From Source"
|
||||
|
||||
```sh
|
||||
mix pleroma.database prune_task
|
||||
```
|
|
@ -17,6 +17,24 @@ def prune_deletes do
|
|||
|> Repo.delete_all(timeout: :infinity)
|
||||
end
|
||||
|
||||
def prune_undos do
|
||||
before_time = cutoff()
|
||||
|
||||
from(a in Activity,
|
||||
where: fragment("?->>'type' = ?", a.data, "Undo") and a.inserted_at < ^before_time
|
||||
)
|
||||
|> Repo.delete_all(timeout: :infinity)
|
||||
end
|
||||
|
||||
def prune_removes do
|
||||
before_time = cutoff()
|
||||
|
||||
from(a in Activity,
|
||||
where: fragment("?->>'type' = ?", a.data, "Remove") and a.inserted_at < ^before_time
|
||||
)
|
||||
|> Repo.delete_all(timeout: :infinity)
|
||||
end
|
||||
|
||||
defp cutoff do
|
||||
DateTime.utc_now() |> Timex.shift(days: -@cutoff)
|
||||
end
|
||||
|
|
|
@ -15,6 +15,12 @@ def perform(_job) do
|
|||
Logger.info("Pruning old deletes")
|
||||
ActivityPruner.prune_deletes()
|
||||
|
||||
Logger.info("Pruning old undos")
|
||||
ActivityPruner.prune_undos()
|
||||
|
||||
Logger.info("Pruning old removes")
|
||||
ActivityPruner.prune_removes()
|
||||
|
||||
Logger.info("Pruning old tombstone delivery entries")
|
||||
ObjectPruner.prune_tombstoned_deliveries()
|
||||
|
||||
|
|
Loading…
Reference in a new issue