4

I'm subscribed to the newsletter, and getting it every week just fine. (MSE in this case, but pretty sure the below happens on all sites.)

However, now I noticed the "Love this site?" box for the first time since subscribing to it, which shouldn't appear since I'm already signed up for it.

Clicking the "Sign up for the newsletter" button throws an error: (no surprise there)

error when trying to sign up for newsletter

Can the previous behavior please be restored, so that the banner won't show when already signed up for the newsletter?

  • Well, that’s how it should work. I blame caching; taking a look now – Dean Ward Jan 24 '18 at 12:03
  • @Dean you mean I should see the banner even when already signed up for newsletter? But I never saw it here even once in the whole time since subscribing, and I visit MSE a lot. – Shadow The Princess Wizard Jan 24 '18 at 12:12
  • No, I meant the intended behaviour is not to be visible once subscribed. Something up with a cache I think – Dean Ward Jan 24 '18 at 12:14
  • @Dean oh, lol. Thanks. Reflecting back, there's a chance I was logged out when seeing this, see this comment I made. (I took the screenshot couple of hours before submitting this question), can you maybe see the error logs? – Shadow The Princess Wizard Jan 24 '18 at 12:20
  • @Dean update: saw this again just now, when surely logged in. What cache you mean? I subscribed months ago, maybe year. – Shadow The Princess Wizard Jan 24 '18 at 12:30
  • There's a cache of newsletters that you are subscribed to. Suspect that it isn't populated correctly in certain circumstances... – Dean Ward Jan 24 '18 at 12:31
  • @Dean maybe related to the change you made mentioned in this other report? e.g. by removing them from SE.com you removed bit... too much? :) – Shadow The Princess Wizard Jan 24 '18 at 12:33
  • Unrelated - that one isn't fixed yet :) – Dean Ward Jan 24 '18 at 12:34
  • I saw this behavior, also here on MSE, for the first time a couple days ago. – Monica Cellio Jan 24 '18 at 19:32
5
+500

Wheeeee, this was a hard one to track down... Essentially this is a long standing bug related to ad caching that was exaggerated by another bug in the newsletter ad rendering path. It manifested itself when there is a race between anonymous and registered users.

Ads are heavily cached and the cache key is constructed based upon a number of parameters. One of those parameters is whether you are subscribed to a newsletter. Registered users can either be subscribed or not subscribed and anonymous users are always not subscribed. In the backend we had checks for anonymous users that weren't respected in the rendering code.

That meant that when an anonymous user visited the site (and the cache was not primed) the HTML would incorrectly contain the newsletter ad and it would subsequently be cached under the key for unsubscribed users. When an unsubscribed registered user came along it simply rendered the previously cached HTML.

In the rare case that an unsubscribed registered user came to the site (and the cache was not primed) then the correct output would be displayed.

That HTML also had a URL to a specific user - the user that hit it with an unprimed cache. Clicking subscribe would attempt to subscribe using that users identifier. Fortunately the backend prevents such shenanigans - hence the error message.

Fun, fun, fun... fix is deployed to production now!

  • Whoa.... awesome job! Thanks a million for the bug fix, and even more for the juicy details! It's like a chef sharing his baking process. ;) – Shadow The Princess Wizard Jan 24 '18 at 20:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .