# 更新到 3.4.0.beta1-dev 后大量出现 HTTP 502 和 429 错误

**URL:** <https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896>\
**Category:** Self-hosting\
**Created:** [2024年八月9日 13:33 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896 "2024-08-09T13:33:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月9日 13:33 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/1 "2024-08-09T13:33:46Z")

</div>

Discourse 版本：3.4.0.beta1-dev ([bf3d8a0a94](https://github.com/discourse/discourse/commits/bf3d8a0a94e8a96472a582b0a7505c1f5faa706c))

昨天更新后，我按照此处的建议禁用了 Cloudflare 的 minify 功能：

> [@Resolving "SyntaxError: Unexpected identifier #..." caused by Cloudflare Auto Minify](https://meta.discourse.org/t/resolving-syntaxerror-unexpected-identifier-caused-by-cloudflare-auto-minify/311390?u=crius):
>
> Cloudflare’s [‘Auto Minify’](https://developers.cloudflare.com/speed/optimization/content/auto-minify/) feature will break recent versions of Discourse. In the browser console, you will see an error like: Uncaught SyntaxError: Unexpected identifier '#...' Cloudflare are aware of the issue, and have added this message to their dashboard: Note: Please note that this feature may not be fully compatible with certain newer CSS and JS language features, which could potentially affect the functionality of the site Unfortunately, despite this critical issue, the feature wi…

然而，从那时起，许多用户（包括我）都遇到了多次 502（网关错误）和 529（请求过多）的错误。

为了尝试缓解这个问题，我还遵循了本指南：

> [@Using Discourse with Cloudflare: Best Practices](https://meta.discourse.org/t/using-discourse-with-cloudflare-best-practices/293405?u=crius):
>
> Using Discourse with Cloudflarebookmark This guide explains how to configure and use Discourse with Cloudflare, including security best practices and troubleshooting tips. person_raising_hand Required user level: Administrator information_source Console access is required for self-hosted installations Summary Cloudflare can enhance your Discourse instance with improved performance through CDN, additional security layers like DDoS protection, and HTTPS support. This guide covers the…

但这些错误的发生频率似乎没有任何改变。

更新发生在昨天上午 11 点左右。我进行了完全重建，因为我还想禁用一个插件。

我有一个 Prometheus+Grafana 实例来监控服务器和 discourse，但服务器在加载方面似乎没问题：

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/a/d/1adbcb0f9bb4dc28a3b83cfa9068671f3d7caf69.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/d/c/1dc4f424788d12afef0c97d6681519e6d4bec4f8.png)

Discourse 指标（昨天上午 11 点左右指标下降是重建导致容器关闭）：

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/e/8/ce8216eab69a0753bbc129a3425ef6750dfcb4ea.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/a/7/d/a7dfecf99398a1e16780d0bac27a05479fcd5c00.png)

同样，我没有看到任何奇怪的模式。

然而，这是刚才浏览器控制台的截图，在我尝试向用户发送私信后：

 ![image](https://global.discourse-cdn.com/meta/original/4X/4/5/b/45b510e598f4640514d0e51ca3dc062c180821f5.png)

如果还需要其他任何信息（任何类型的日志），请随时提出。谢谢。

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月9日 13:37 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/2 "2024-08-09T13:37:10Z")

</div>

另外，如果这有帮助的话，“后台”的许多实时操作也明显滞后。

例如，已读主题未被注册为已读。

---

<div class="post-metadata">

**Author:** ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)\
**Post date:** [2024年八月9日 13:40 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/3 "2024-08-09T13:40:59Z")

</div>

只是为了确保，你也完成了这一步，然后重新构建，对吗？

> [@在 Cloudflare 中使用 Discourse：最佳实践，post:1](#):
>
> ## 自托管用户的额外配置
> 
> 为确保正确的 IP 地址发送到 Discourse，您需要在 `containers/app.yml` 的末尾添加以下行。
> 
> ```plaintext
> cloudflare.template.yml
> 
> ```
> 
> （相关：[如何设置 Cloudflare？ - #6 by codinghorror](https://meta.discourse.org/t/how-do-you-setup-cloudflare/32258/6)）

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月9日 16:03 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/4 "2024-08-09T16:03:19Z")

</div>

是的，抱歉，我忘了补充，很久以前我已经将 Cloudflare 模板添加到了 app.yml 文件中。我们从第一天起就一直使用 Cloudflare。

这是 app.yml 的一部分，我们有自己的证书独立续订，这就是为什么 letsencrypt 的被注释掉了：

```plaintext
## 这是集成式、独立的 Discourse Docker 容器模板
##
## 更改此文件后，您必须重建
## /var/discourse/launcher rebuild app
##
## 编辑时请务必*非常*小心！
## YAML 文件对空格或对齐错误非常非常敏感！
## 如有需要，请访问 http://www.yamllint.com/ 来验证此文件

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
## 如果您想添加 Lets Encrypt (https)，请取消注释这两行
  - "templates/web.ssl.template.yml"
# - "templates/web.letsencrypt.ssl.template.yml"
  - "templates/cloudflare.template.yml"

## 此容器应暴露哪些 TCP/IP 端口？
## 如果您希望 Discourse 与 Apache 或 nginx 等其他 Web 服务器共享端口，
## 请参阅 https://meta.discourse.org/t/17247 获取详细信息
expose:
  - "80:80" # http
  - "443:443" # https

[...]

```

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月9日 16:16 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/5 "2024-08-09T16:16:12Z")

</div>

`/logs` 的摘录

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

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月9日 18:30 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/6 "2024-08-09T18:30:38Z")

</div>

我看到这被移到了 #Installation，只是为了清楚起见，这不是新安装。

这个 discourse 实例自 2023 年 3 月以来一直在运行，从未出现过这个特定问题。

过去曾出现过一些 529 问题，但后来已得到解决。

---

<div class="post-metadata">

**Author:** ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)\
**Post date:** [2024年八月9日 18:57 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/7 "2024-08-09T18:57:53Z")

</div>

> [@Crius](#):
>
> 这不是新安装。

我认为它仍然适合

> **[Installation](https://meta.discourse.org/c/installation/31)**
>
> Getting Discourse up and running, keeping it going, updating, and any other general sysadmin maintenance.

---

<div class="post-metadata">

**Author:** ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)\
**Post date:** [2024年八月9日 20:18 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/8 "2024-08-09T20:18:56Z")

</div>

看起来您的 PostgreSQL 已不堪重负。看起来您的大部分 RAM 都处于空闲状态，我建议尝试调整数据库以使用它，然后看看情况如何。

---

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [2024年八月9日 22:43 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/9 "2024-08-09T22:43:30Z")

</div>

`/sidekiq/queues` 是什么样子的？  
您是从哪个版本更新的？

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月10日 00:16 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/10 "2024-08-10T00:16:27Z")

</div>

从 5 月 6 日的最新稳定版 [v3.2.1](https://github.com/discourse/discourse/releases/tag/v3.2.1) 到最新的 `test-passed`。

Sidekiq 队列：

 ![image](https://global.discourse-cdn.com/meta/original/4X/4/5/5/455b4b4632c562cd54fc602130348d5e6118104f.png)

Dead job 部分是这个，但似乎自古以来就是同一个 job。

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/8/a/98a0c6c579f1525e44ac42af0576a00e1e937d90.png)

最旧的条目：

 ![image](https://global.discourse-cdn.com/meta/original/4X/a/0/0/a0042510056b60abdcbbf71abc2669fb0de69b9d.png)

重试中的似乎是同一个 job 被一遍又一遍地重试。

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月10日 00:18 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/11 "2024-08-10T00:18:55Z")

</div>

> [@Falco](#):
>
> 看起来您的 PostgreSQL 已不堪重负。看起来您的大部分 RAM 都处于空闲状态，我建议尝试调整数据库以使用它，看看之后情况如何。

但是……为什么突然出现这种情况？仅仅是应用程序层更新之后？

我正在使用 discourse prometheus exporter 插件。  
如果我在虚拟机上添加一个 postgresql exporter 作为另一个容器，是否可以允许它访问 discourse postgresql 安装上的指标？

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月11日 23:59 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/12 "2024-08-11T23:59:48Z")

</div>

关于如何微调 discourse 的数据库，是否有更精确的指导？

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月12日 13:52 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/13 "2024-08-12T13:52:29Z")

</div>

不确定是否相关，但这肯定是在更新后开始发生的，点击未读标签中的“忽略”按钮总是返回 503。

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月13日 08:12 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/14 "2024-08-13T08:12:26Z")

</div>

既然似乎没有解决方案，我将尝试回滚到最新的 `stable` 版本，因为它应该是……你知道的，_稳定的_。

祈祷没有核心依赖项破坏构建过程，[就像上次一样](https://meta.discourse.org/t/breaking-change-for-people-on-stable-versions-v3-2-1-and-down-with-discourse-docker/308680?u=crius)。

---

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [2024年八月13日 08:43 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/15 "2024-08-13T08:43:07Z")

</div>

> [@Crius](#):
>
> 尝试回到最新的 `stable` 版本，因为它本应如此

你不能从 tests-passed 回到 stable，除非有更高版本的 stable 可用。所以你下次有机会是在 3.4.0 发布时，我估计那是在圣诞节左右或之后……

再说，你总有一天得咬紧牙关挺过去。

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月13日 08:53 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/16 "2024-08-13T08:53:03Z")

</div>

好吧，我刚做完了。似乎在工作。反正我们也不关心 3.3.0 中的任何功能。

我会看看是否还有问题。最坏的情况是我们仍然会遇到大量的 429 和 502，变化不大。

[如果能指导我如何配置 Discourse 上的 Postgres 以获得更多可用资源，我将不胜感激。](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/8?u=crius)

编辑：已部署 3.2.5 版本。系统似乎稳定。

---

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [2024年八月13日 08:54 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/17 "2024-08-13T08:54:55Z")

</div>

> [@Crius](#):
>
> 嗯，我刚做完了。看起来是可行的。反正我们也不关心 3.3.0 中的任何功能。

下次报告问题时，请提醒我们你已完成此操作 😉

---

<div class="post-metadata">

**Author:** ![Crius](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/crius/32/317214_2.png) [@Crius](https://meta.discourse.org/u/Crius)\
**Post date:** [2024年八月13日 08:59 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/18 "2024-08-13T08:59:21Z")

</div>

> [@RGJ](#):
>
> 除非有更高的稳定版本可用，否则您无法从“已通过测试”回退到“稳定”版本。因此，您的下一个机会是当 3.4.0 发布时，我估计是在圣诞节前后……  
> 而且，您总有一天必须咬紧牙关。

我总是在报告问题时提及我所在的版本。  
我认为重要的是要记住，正是因为这是开源软件，所以应该考虑关键问题，而不是写诸如以下内容：

> 这是人们不遗余力地切换到“稳定”版本，遇到一些因未部署最受欢迎的版本而出现的 bug 的又一个例子。

当 `stable` 应该意味着“稳定”，而不是“遗留”时。  
像 discourse docker 这样的核心依赖项在没有标签系统的情况下被推送的事实，足以让您在回应报告问题的用户时稍微谦虚一点。

---

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [2024年八月13日 09:03 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/19 "2024-08-13T09:03:49Z")

</div>

> [@Crius](#):
>
> 我发帖报告问题时，总是会提及我所处的版本。

我当时说的是，当你技术上无法降级时，提及你降级的事实。

我认为记住这一点很重要……我不为 Discourse 工作，我是在利用自己的业余时间帮助你，所以我并不欣赏你的语气，也无法处理你的反馈。

---

<div class="post-metadata">

**Author:** ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)\
**Post date:** [2024年八月13日 09:05 UTC](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896/20 "2024-08-13T09:05:37Z")

</div>

> [@Crius](#):
>
> 当 `stable` 应该意味着“稳定”，而不是“遗留”。

> [@Discourse](#):
>
> ### stable
> 
> 在 GitHub 上：[GitHub - discourse/discourse at stable](https://github.com/discourse/discourse/tree/stable)
> 
> stable 分支不一定比 **tests-passed** 更“稳定”。它更多地是关于这样一个理念：bug 是已知的，并且它作为特定功能和改进的检查点。使用 **tests-passed** ，可能会引入新的 bug，然后在几个提交后修复。

[下一頁](https://meta.discourse.org/t/lots-of-http-502-and-429-after-updating-to-3-4-0-beta1-dev/320896.md?page=2)
