dbprune: add more logs
Pruning can go on for a long time; give admins some insight into that something is happening to make it less frustrating and to make it easier which part of the process is stalled should this happen. Again most of the changes are merely reindents; review with whitespace changes hidden recommended.
This commit is contained in:
parent
1d4c212441
commit
24bab63cd8
1 changed files with 94 additions and 77 deletions
|
@ -68,6 +68,8 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
"""
|
||||
|> Repo.query([], timeout: :infinity)
|
||||
|
||||
Logger.info("Prune activity singles: deleted #{del_single} rows...")
|
||||
|
||||
# Prune activities who link to an array of objects
|
||||
{:ok, %{:num_rows => del_array}} =
|
||||
"""
|
||||
|
@ -88,6 +90,8 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
"""
|
||||
|> Repo.query([], timeout: :infinity)
|
||||
|
||||
Logger.info("Prune activity arrays: deleted #{del_array} rows...")
|
||||
|
||||
del_single + del_array
|
||||
end
|
||||
|
||||
|
@ -222,6 +226,7 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
|
||||
Logger.info(log_message)
|
||||
|
||||
{del_obj, _} =
|
||||
if Keyword.get(options, :keep_threads) do
|
||||
# We want to delete objects from threads where
|
||||
# 1. the newest post is still old
|
||||
|
@ -288,9 +293,12 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
end
|
||||
|> Repo.delete_all(timeout: :infinity)
|
||||
|
||||
Logger.info("Deleted #{del_obj} objects...")
|
||||
|
||||
if !Keyword.get(options, :keep_threads) do
|
||||
# Without the --keep-threads option, it's possible that bookmarked
|
||||
# objects have been deleted. We remove the corresponding bookmarks.
|
||||
{:ok, %{:num_rows => del_bookmarks}} =
|
||||
"""
|
||||
delete from public.bookmarks
|
||||
where id in (
|
||||
|
@ -301,12 +309,16 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
)
|
||||
"""
|
||||
|> Repo.query([], timeout: :infinity)
|
||||
|
||||
Logger.info("Deleted #{del_bookmarks} orphaned bookmarks...")
|
||||
end
|
||||
|
||||
if Keyword.get(options, :prune_orphaned_activities) do
|
||||
prune_orphaned_activities()
|
||||
del_activities = prune_orphaned_activities()
|
||||
Logger.info("Deleted #{del_activities} orphaned activities...")
|
||||
end
|
||||
|
||||
{:ok, %{:num_rows => del_hashtags}} =
|
||||
"""
|
||||
DELETE FROM hashtags AS ht
|
||||
WHERE NOT EXISTS (
|
||||
|
@ -315,9 +327,14 @@ defmodule Mix.Tasks.Pleroma.Database do
|
|||
"""
|
||||
|> Repo.query()
|
||||
|
||||
Logger.info("Deleted #{del_hashtags} no longer used hashtags...")
|
||||
|
||||
if Keyword.get(options, :vacuum) do
|
||||
Logger.info("Starting vacuum...")
|
||||
Maintenance.vacuum("full")
|
||||
end
|
||||
|
||||
Logger.info("All done!")
|
||||
end
|
||||
|
||||
def run(["prune_task"]) do
|
||||
|
|
Loading…
Reference in a new issue