Our discource is runing out of space on server.
We did bulk deleted old posts whit uploads.
But We did not gain any space.
When I query table topics they only havetopics.deleted_by_id is not null
Uploads for these topics are still on server.
Is there any way to make this Uploads orphans so sidekiq can clean these?
Or is there any way to PRUGE deleted topics so they do not consume space any more ?
Not sure how you bulk deleted the old posts/topics but this should fix it
# ssh into server
cd /var/discourse
./launcher enter app
rails db
DELETE FROM post_uploads WHERE post_id IN (SELECT id FROM posts WHERE deleted_at IS NOT NULL)
This tsql delete uploads from post whic is not deletete but belong to topics whic is deleted.
I do no why discource left undeleted posts when topic is deleted.
But from my poin of view.
If topic is deleted, then all posts shoud be deleted in topics. Not just first one.
This script delete uploads for all posts which belong to deleted topic no matter if post is deleted or not.
delete from public.post_uploads
where id in (
SELECT
post_uploads.id
-- ,uploads.filesize
-- ,posts.id
--,topics.id
FROM
public.topics
inner join public.posts on topics.id=posts.topic_id
inner join public.post_uploads on posts.id=post_uploads.post_id
inner join public.uploads on post_uploads.upload_id=uploads.id
WHERE
topics.deleted_by_id is not null
)
I am not for sure which of sidekiq jobs need to be triggered , but I get released space after manual triggering next Workers in scheduler