# Sporadic missing letter avatars (cache problem?)

**URL:** https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304
**Category:** Bug
**Created:** [10월 9, 2015, 6:55오전 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304 "2015-10-09T06:55:43Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [10월 8, 2015, 6:08오후 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/1 "2015-10-08T18:08:28Z")

</div>

I’ve been seeing a sporadic problem with avatars loading as well.  
Seems to always be new members that I haven’t “seen” before.  
I’ve been having cable connection problems lately (finally found it was due to a sharply bent telephone line in the telephone base) so I had thought it was at my end only.

In all cases (except when a dropped connection) a page refresh has brought up the avatars.

It hasn’t happened consistently enough (often, but not consistently) and I haven’t tried debugging, but I’ll look more deeply next time it happens.

EDIT  
And it just happened. I went to [https://meta.discourse.org/t/vagrant-appears-not-be-setting-a-real-localhost/34248](https://meta.discourse.org/t/vagrant-appears-not-be-setting-a-real-localhost/34248)

And got this until I reloaded the page.

 ![](https://global.discourse-cdn.com/meta/original/3X/3/f/3fc803b56fa9c49aa56f51017e3a14d95e577ac1.png)

Checking the mark-up before and after looks the same, so maybe it’s some kind of cache issue?

**initial page load**

```plaintext
<div class="topic-avatar">

        <a href="/users/gustavo_souza" classnames="trigger-user-card main-avatar" data-user-card="gustavo_souza">
<img alt="" src="https://avatars.discourse.org/v2/letter/g/41988e/45.png" class="avatar" title="gustavo_souza" height="45" width="45">
</a>

      <!---->
    </div>

```

**after page reload**

```plaintext
<div class="topic-avatar">

        <a href="/users/gustavo_souza" classnames="trigger-user-card main-avatar" data-user-card="gustavo_souza">
<img alt="" src="https://avatars.discourse.org/v2/letter/g/41988e/45.png" class="avatar" title="gustavo_souza" height="45" width="45">
</a>

      <!---->
    </div>

```

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [10월 8, 2015, 10:00오후 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/2 "2015-10-08T22:00:48Z")

</div>

Interesting… thanks for that additional info, @Mittineague. I don’t believe I’ve seen that particular behaviour, but I’ll keep a closer eye out in the future. I’d say you’re right, that it’s a caching issue, but tracking down exactly where the bug is is going to be fun times. Does the Chrome devtools console show any errors loading the avatar URL? I find that if there’s a failed asset load, the exact problem is usually reported in the console, so that might give us some clues to start with.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [10월 9, 2015, 3:28오전 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/3 "2015-10-09T03:28:42Z")

</div>

> [@mpalmer](#):
>
> tracking down exactly where the bug is is going to be fun times

I’ve been running Firefox with Network open - on two Discourse forums - waiting for it to happen again.

I’m becoming more convinced this isn’t a Bug, but rather a Heisenbug

> **[Heisenbug](https://en.wikipedia.org/wiki/Heisenbug)**
>
> In computer programming jargon, a heisenbug is a software bug that seems to disappear or alter its behavior when one attempts to study it. The term is a pun on the name of Werner Heisenberg, the physicist who first introduced the uncertainty principle, and it is a reference to the observer effect, which states that the act of observing a system inevitably alters its state. In electronics, the traditional term is probe effect, where attaching a test probe to a device changes its behavior. The Si...

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [10월 9, 2015, 6:19오전 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/4 "2015-10-09T06:19:49Z")

</div>

> [@mpalmer](#):
>
> down to an SSL incompatibility.

(sorry for hijacking, and I have Win 7 until I get the nerve to do the upgrade to Win 10)

I still have feeling it’s cache related.

It hasn’t happened again for me with the “post” avatar yet, but it just happened with a User Card avatar.

 ![](https://global.discourse-cdn.com/meta/original/3X/0/5/059fd8c94f2912f8bef8f97ec0ff7c813dae6851.png)

.

 ![](https://global.discourse-cdn.com/meta/original/3X/9/d/9df70fc938fd3db3c346d2467aa486412f2bd589.png)

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [10월 10, 2015, 5:06오전 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/5 "2015-10-10T05:06:23Z")

</div>

@mpalmer - is it possible that there’s some interim state where:

- a request for the avatar is pending
- the target file has been created but not written to
- another request comes in and reads the newly created 0-byte file; this gets cached
- the original request completes

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [10월 11, 2015, 10:10오후 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/6 "2015-10-11T22:10:10Z")

</div>

That sounds entirely plausible, @riking. I’ll go through the code this morning and try and confirm your hypothesis. Thanks.

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [10월 20, 2015, 2:22오전 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/7 "2015-10-20T02:22:51Z")

</div>

An update on this topic:

1. I’ve gone through the code, and confirmed that the avatar file is generated in a temporary location and then moved into place, which should mean it’s atomic and there’s no possibility of the file being empty at any point. The creation and move is all happening on one filesystem, too.
2. I’ve greatly increased the amount of logging we’re doing on avatar service, so @Mittineague, if you get the problem again on any forum that’s using our letter avatars service, if you can give me a time (to within a couple of minutes) and the exact URL that misbehaved and then came good (and, preferably, the IP address you were using), then I should be able to see exactly what’s going wrong.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [10월 20, 2015, 3:39오후 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/8 "2015-10-20T15:39:00Z")

</div>

> [@mpalmer](#):
>
> if you get the problem again on any forum that’s using our letter avatars service,

Around 11:20 AM Eastern Daylight Time

[http://community.sitepoint.com/t/get-the-tiff-image-through-curl/205195/2?u=mittineague](http://community.sitepoint.com/t/get-the-tiff-image-through-curl/205195/2?u=mittineague)

```plaintext
<a href="/users/stephan2307" classnames="trigger-user-card main-avatar" data-user-card="stephan2307">
<img alt="" src="https://avatars.discourse.org/letter/s/34f0e0/45.png" class="avatar" title="stephan2307" height="45" width="45">
</a>

```

Hovering over the img src in dev tools shows a toolitp with  
“Could not load the image”

71.192.198.203  
or IPV6  
2601:19b:4100:1ac9:b9da:50c1:4d32:ed5d

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [10월 20, 2015, 11:20오후 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/9 "2015-10-20T23:20:24Z")

</div>

Ah, you’re a legend, @Mittineague! That’ll do very nicely.

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [10월 20, 2015, 11:30오후 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/10 "2015-10-20T23:30:50Z")

</div>

Hmm, I’m having trouble finding any relevant-looking requests in the logs. Can you PM me the source IP address of the requests? Also, for clarity, _which_ Eastern Daylight Time are you using? (I’m currently assuming UTC-0400, America/New\_York).

---

<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: [6월 22, 2016, 10:25오후 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/11 "2016-06-22T22:25:21Z")

</div>

We had a memory leak in the avatars process since forever, but I set up a weekly task to restart the avatars container about a month ago, so all should be well. I’ve verified that memory is under control since then.

---

<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: [6월 22, 2016, 10:25오후 UTC](https://meta.discourse.org/t/sporadic-missing-letter-avatars-cache-problem/34304/12 "2016-06-22T22:25:28Z")

</div>


