# 上传：recover\_from\_tombstone 未恢复图片

**URL:** https://meta.discourse.org/t/uploads-recover-from-tombstone-not-resurrecting-images/78295
**Category:** Bug
**Created:** [2018年一月17日 15:58 UTC](https://meta.discourse.org/t/uploads-recover-from-tombstone-not-resurrecting-images/78295 "2018-01-17T15:58:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Curtis\_Rueden](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/curtis_rueden/32/84277_2.png) [@Curtis\_Rueden](https://meta.discourse.org/u/Curtis_Rueden)
#### Post date: [2018年一月17日 15:58 UTC](https://meta.discourse.org/t/uploads-recover-from-tombstone-not-resurrecting-images/78295/1 "2018-01-17T15:58:29Z")

</div>

## Summary

I believe the `uploads:recover_from_tombstone` script is not restoring everything it should from the tombstone. My reasoning is as follows:

Recently, our Discourse forum had a problem where uploaded images would no longer appear:

> **[Inability to see images since Dec 30](https://forum.image.sc/t/inability-to-see-images-since-dec-30/8629)**
>
> Hello! Is anyone else having problems viewing some of the images? For example, I can’t see @quokka79 or @Paul\_Guichard’s logos. I’ve tried using chrome and firefox on linux and mac, but they don’t appear. I also did a hard refresh and cleared my...

And [here](http://forum.imagej.net/t/contest-new-imagej-logo/8485/16) is an example topic illustrating the issue.

## Description

The problem began around December 30. I investigated yesterday, and events unfolded as follows:

1. I upgraded to the latest version of Discourse (v2.0.0.beta1 +123) hoping it would magically fix the issue. But sadly not.

2. We noticed that automatic backup was stuck in a pending state since two weeks. I canceled it via the web interface.

3. I noticed Sidekiq was clogged with a huge number (\>200,000) of pending jobs—mainly digest mails. Jobs were being processed, but the queue was growing too fast to keep up. I decided to go for the [nuclear option](https://meta.discourse.org/t/sidekiq-queue-keeps-growing/58956/15) and `flushall`. Since then, the Sidekiq queue has been under control.

4. I saw that the broken images still had `src="transparent.png"` and `data-orig-src="upload://..."`. I tried to run the `uploads:recover_from_tombstone` script (described [here](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/2)) to see if it could fix things, but the problem persisted.

5. I did some digging to find out whether the missing images were really gone:

6. I tried running `rake:recover_from_tombstone` again today; here is the abbreviated output:

## Questions

1. _ **Is this a bug or limitation of the recovery script?** _ Looking at [the source of that routine](https://github.com/discourse/discourse/blob/v2.0.0.beta1/lib/tasks/uploads.rake#L393-L463), I guess it only checks the `src` of each `img` and does not look at any `data-orig-src` attribute? Should it? Apologies if I am misreading things; my Ruby-fu is very weak.

2. _ **How should I proceed to fix my forum?** _ I read on other threads that it is best not to manually copy things out of the tombstone. I am concerned that if I don’t fix this before Friday—when we migrate to hosted Discourse, woohoo! 🎆—these images will be permanently lost.

3. _ **Is it normal that even since yesterday, some additional images were recovered from the tombstone today?** _ Is this typical? Or is it indicative of some other bug? How can I check?

4. _ **Why are these images ending up in the tombstone in the first place?** _ Is there an outstanding bug here? Should I have been [disabling Sidekiq during upgrades](https://meta.discourse.org/t/old-image-uploads-become-broken-images/47236/5)?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2018年一月18日 00:20 UTC](https://meta.discourse.org/t/uploads-recover-from-tombstone-not-resurrecting-images/78295/3 "2018-01-18T00:20:26Z")

</div>

I believe @zogstrip will be looking at this.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2018年一月19日 14:41 UTC](https://meta.discourse.org/t/uploads-recover-from-tombstone-not-resurrecting-images/78295/8 "2018-01-19T14:41:01Z")

</div>

I’ve pushed a fix, can you try recovering images again?

[https://github.com/discourse/discourse/commit/2d49250107b3abb5e7d433de540810aa378c8f47](https://github.com/discourse/discourse/commit/2d49250107b3abb5e7d433de540810aa378c8f47)

---

<div class="post-metadata">

### Author: ![Curtis\_Rueden](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/curtis_rueden/32/84277_2.png) [@Curtis\_Rueden](https://meta.discourse.org/u/Curtis_Rueden)
#### Post date: [2018年一月19日 16:44 UTC](https://meta.discourse.org/t/uploads-recover-from-tombstone-not-resurrecting-images/78295/9 "2018-01-19T16:44:11Z")

</div>

> [@zogstrip](#):
>
> I’ve pushed a fix, can you try recovering images again?

Thank you so much @zogstrip!

I had to add `require "base62"` to the top of the new `uploads.rake`, but then it worked! 🍻

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [2018年一月19日 16:52 UTC](https://meta.discourse.org/t/uploads-recover-from-tombstone-not-resurrecting-images/78295/10 "2018-01-19T16:52:51Z")

</div>

> [@Curtis\_Rueden](#):
>
> I had to add require “base62” to the top of the new uploads.rake, but then it worked! 🍻

Forgot about that, I only tested in “`dev`” environment and it worked fine without it.

[https://github.com/discourse/discourse/commit/b6c9d7a9d215a92d07fc545ae438056756245a98](https://github.com/discourse/discourse/commit/b6c9d7a9d215a92d07fc545ae438056756245a98)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2018年四月23日 00:23 UTC](https://meta.discourse.org/t/uploads-recover-from-tombstone-not-resurrecting-images/78295/11 "2018-04-23T00:23:21Z")

</div>


