How can I detect and remove any orphan attachments in jira attachments directory?

Sorin Sbarnea (Citrix)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 14, 2012

I have a 500GB attachments directory on Jira and I would like to do some cleanup there, if possible.

I only assume that maybe, in time we got some orphan attachments that we do not need anymore - removed attachemnts in jira db, but not from disk (example when you delete an issue).

1 answer

1 accepted

1 vote
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 14, 2012

I think you should check that assumption first, otherwise you're going to cause problems. Better to work out an attachment limit, and see which issues have attachments over that size.

select sum(filesize) from FILEATTACHMENT - run that on that on your db - if it's less than the size on disk, allowing for disk block sizes etc, then maybe you have orphaned attachments.

Sorin Sbarnea (Citrix)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2013

Thanks, Jamie but this not quite an answer, as it does not indicate you the orphan files. Still, it seems that there is no huge difference between the size on disk and the sum(filesize).

The strange thing is the even if I do have ~28,000 attachments, I count over 500,000 files on the attachment partition. I would expect to see up to the double due to the thumbnailsm but why this huge number?

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2013

Well - you've made the presumption that there can be orphaned files, and I don't think that's the case.

Sorin Sbarnea (Citrix)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2013

Anyway, do you have any idea why there are so many files? Is there a fix for this, one that would speedup the chmod/chown executed by jira installer?

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2013

How are you calculating the number of files on disk, using a "find . -type f" ? I presume you're not doing something odd like auto-versioning with subversion, so I think you need to give some examples of files that are on disk but not in the database.

Suggest an answer

Log in or Sign up to answer