For the past week or so (after the most recent upgrade?), I’ve noticed that some users’ uploaded images are broken. It is clear that they are pasting an image, as the code in their post looks like that, but the files are missing.
For example, this post (raw version has three broken images in it. I cannot imagine what the user could have done to break them. And stranger still, sometimes a post will have some images that work fine, but others that are missing. I’ve done find in the uploads directory and the files aren’t there anywhere.
I can’t see any rhyme or reason to it. Has anyone else noticed a similar problem lately?
Lest anyone thinks that this query went unanswered, many thanks to @zogstrip for solving this. It seems that Discourse got confused about whether those uploaded images were being used and moved them for subsequent deletion.
Though you will probably never need it, the fix went something like this:
# copy the "deleted" images from their to-be-deleted staging area
cd /var/discourse
./launcher enter app
rake uploads:recover_from_tombstone
# rebake to see that it doesn't happen again
rake posts:rebake
So anyone finding this thread now, you can probably skip the second part (unless I am mistaken! I am new to this).
Since this is the only place I found information about this fix, and the two commands take a very long time to run (over 12 hours here), I wanted to update the thread to help save time for anyone else.
Have some odd problems on my new forum (imported from phpBB), where attachments keep being deleted. Initially, it may have been due to me setting the grace period too low and things being deleted as their corresponding posts were still in the import queue, but a few things still seem to be getting deleted, which I’ve not got to the bottom of yet.
We have seen this happen a few times, immediately after an update.
Since we found this out, we have been disabling Sidekiq during the upgrade and this issue never happened again.
A couple of issues I have encountered with broken upload links:
My board has a non-traditional file upload enabled (mp3) and Discourse was going through deleting all uploads older than 48 hours. I have resolved this by unchecking clean up uploads in admin.
If you host uploads on Amazon S3 rake uploads:recover_from_tombstone will not work. You get this error instead: This task only works for internal storages
Is there a way to keep the remove orphan unreferenced uploads option enabled and have it recognise and not delete non-regular files (such as mp3)?
I rebuild the app and restarted the server (as it seems to have a problem with sidekiq) and then I did a hack (?) but it this seems to work for all the broken images:
./launcher enter app
cp public/uploads/tombstone/default/original/1X/* public/uploads/default/original/1X/
URGENT: FATAL: Peer authentication failed for user "discourse"
Failed to initialize site default
rake aborted!
PG::ConnectionBad: FATAL: Peer authentication failed for user "discourse"
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
...
Yes. I’ve started using it with a very early version (I think I started with the first docker shipped version) but the upgrades always went without problems, except recently (but was ‘fixable’)