# Users reporting lots of 502 errors when attempting to post due to "max consecutive replies" check

**URL:** https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921
**Category:** Bug
**Created:** [22 בדצמבר,‏ 2018,‏ 8:45pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921 "2018-12-22T20:45:44Z")
**Posts on this page:** 18
**Page:** 2

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [17 בינואר,‏ 2019,‏ 2:16pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/21 "2019-01-17T14:16:22Z")

</div>

I think I may have narrowed it down a bit. I was unable to replicate the 502 errors on my mod/admin account, so I impersonated a user who had the problem and encountered it. When the user hits the submit reply button on a longer thread (4700 posts), the page sits on “saving” for a good 20 seconds before eventually failing to post with a 502 error.

Granting that user moderator status immediately fixes the problem. He was TL2, and granting TL3 did not fix it.

---

<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: [17 בינואר,‏ 2019,‏ 5:25pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/22 "2019-01-17T17:25:51Z")

</div>

That is _very_ interesting, cc @sam. Good sleuthing!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [17 בינואר,‏ 2019,‏ 7:49pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/23 "2019-01-17T19:49:27Z")

</div>

Since this is new, I am guessing this could be due to the consecutive reply check, will have a look later today

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [17 בינואר,‏ 2019,‏ 8:44pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/24 "2019-01-17T20:44:26Z")

</div>

Given we have an easy bypass per:

> <https://github.com/discourse/discourse/blob/384135845b386d4014dd6daf82e61722304e6d32/lib/validators/post_validator.rb#L146-L146>

Can you set `max consecutive replies` in your site settings to 0 and let me know what happens?

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [17 בינואר,‏ 2019,‏ 8:51pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/25 "2019-01-17T20:51:54Z")

</div>

I think that _MAY_ have fixed it-- it isn’t 100% reproducible, and I closed the thread I was testing in earlier, but re-opening it I was not able to reproduce. Will ask the users if they’re seeing any more 502s.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [17 בינואר,‏ 2019,‏ 8:56pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/26 "2019-01-17T20:56:26Z")

</div>

hmmm cause I just tested this query in [data explorer](https://meta.discourse.org/t/32566?silent=true) on a 20k post topic and it is lightning fast.

```sql
SELECT user_id
  FROM posts
 WHERE deleted_at IS NULL
   AND NOT hidden
   AND topic_id = SOME_TOPIC_ID
 ORDER BY post_number DESC
 LIMIT 3

```

I would love to get to the bottom of this.

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [17 בינואר,‏ 2019,‏ 8:59pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/27 "2019-01-17T20:59:32Z")

</div>

Happy to run whatever you want to help debug, but I’m not familiar with postgres or ruby so need some guidance.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [17 בינואר,‏ 2019,‏ 11:26pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/28 "2019-01-17T23:26:13Z")

</div>

Awesome, can you install [Discourse Data Explorer](https://meta.discourse.org/t/data-explorer-plugin/32566) and then run the query above substituting `SOME_TOPIC_ID` with the topic id of the problem topic?

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [18 בינואר,‏ 2019,‏ 12:49am UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/29 "2019-01-18T00:49:34Z")

</div>

All set. The topic I tested earlier:

`3 results. Query completed in 0.5 ms.`

and here is the output from the largest topic on the forum that’s not locked, 15k posts:

`3 results. Query completed in 0.6 ms.`

So seems really fast.

Also so far nobody has seen a 502 error, since we set that parameter to 0.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [18 בינואר,‏ 2019,‏ 2:30am UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/30 "2019-01-18T02:30:15Z")

</div>

Thank you so much for 🐻ing with me.

I believe I just fixed the culprit here:

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

Any chance you can update to latest and re-enable the setting? Let me know if the issue is still gone?

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [18 בינואר,‏ 2019,‏ 4:22am UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/31 "2019-01-18T04:22:20Z")

</div>

Not sure how to update, dashboard says I’m already up to date and running git pull in /var/discourse says the same thing.

---

<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: [18 בינואר,‏ 2019,‏ 5:11am UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/32 "2019-01-18T05:11:33Z")

</div>

Just issue the rebuild from the command line and you should be good. You can time it this way too 😉

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [18 בינואר,‏ 2019,‏ 12:48pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/33 "2019-01-18T12:48:28Z")

</div>

Did you try visiting /admin/upgrade?

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [18 בינואר,‏ 2019,‏ 3:35pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/34 "2019-01-18T15:35:45Z")

</div>

OK, I updated (went to admin/upgrade manually, there was no link in the dashboard) and reverted the consecutive replies setting to 5. So far no errors, asked users to verify.

Thanks again for your help with this! Much appreciated!

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [18 בינואר,‏ 2019,‏ 3:49pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/35 "2019-01-18T15:49:33Z")

</div>

> [@Wingtip](#):
>
> went to admin/upgrade manually, there was no link in the dashboard

There will only be a link from the dashboard when we release a new beta. We add code daily (hourly, even) - if we notified you for every single commit, your site would always say it’s out of date 😉.

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [18 בינואר,‏ 2019,‏ 3:52pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/36 "2019-01-18T15:52:06Z")

</div>

Makes sense, that’s why I tried a git pull earlier also. Anyway it’s upgraded now.

---

<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: [18 בינואר,‏ 2019,‏ 10:33pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/37 "2019-01-18T22:33:18Z")

</div>

Thanks for your diligence in staying on top of this, we found a subtle but important issue as a result.

---

<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: [18 בינואר,‏ 2019,‏ 10:33pm UTC](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921/38 "2019-01-18T22:33:20Z")

</div>



[Previous page](https://meta.discourse.org/t/users-reporting-lots-of-502-errors-when-attempting-to-post-due-to-max-consecutive-replies-check/104921.md?page=1)
