After updating to the latest version of Discourse we now have a strange issue with ngix posting error 502.
Some users get Error 502 when posting, some don’t. Some profiles get 502, some don’t.
CPU usage is around 10 to 25%, RAM usage is about 20% as well.
I tried disabling our 5 plugins, same result.
What logs do I look at to find out what is producing these 502 errors?
Looking in I /var/log/nginx/error.log I seem to randomly get a lot of these, which produces the 502 I assume.
Its just timing out or what?
2025/04/29 18:11:50 [error] 617#617: *419 upstream prematurely closed connection while reading response header from upstream, client: <IP>, server: _, request: "POST /posts HTTP/2.0", upstream: "http://127.0.0.1:3000/posts", host: "forum.domain.com", referrer: "https://forum.domain.com/"
RGJ
(Richard - Communiteq)
April 29, 2025, 6:15pm
4
What was the version prior to the update?
Really old, like a year old or more. Is there a log somewhere I can see what I upgraded from?
Also getting some of these
*2 connect() failed (111: Connection refused) while connecting to upstream,
...
upstream: "http://127.0.0.1:3000/message-bus/92fd28cbf742...
It seems random, suddenly everything is fast and I can post again, and then it goes slow and 502’s start popping up again.
Looking inside the postgres/current log
2025-04-29 18:48:24.709 UTC [1746] discourse@discourse LOG: duration: 606789.911 ms execute <unnamed>: SELECT COUNT(*) FROM "posts" WHERE "posts"."deleted_at" IS NULL
duration: 606789.911 ms
We do have a lot of posts, few users.. why is it using 600k ms on this?
Might it be problems with indexing or such, that makes the queries slow?
I selected the discourse table in postgres and did a REINDEX DATABASE discourse; in the hope of that making things faster.
I assume it will take a very long time.
pfaffman
(Jay Pfaffman)
April 29, 2025, 7:39pm
10
Did you follow the advice in PostgreSQL 15 update ? You might also vaccuum the database.
I did not, I do have the postgres_data_old folder (Albeit in a different directory than in that post).
But then the post goes to say;
“If you are running a setup with a dedicated data container”, which I assume means postgre is running in a dedicated Docker container?
Ours run in the same instance as the forum. So not sure how to progress from there doesn’t seem to be a “if not then” clause?
Does the prescence of the folder means the conversion was okay or?
pfaffman
(Jay Pfaffman)
April 29, 2025, 7:56pm
12
You can check the postgres version at /var/discourse/shared/standalone/postgres_data/PG_VERSION
– If you did a command line upgrade, it’s possible that it did the upgrade and you didn’t notice (but you’d have to have run the rebuild twice). If you upgraded from the web interface, you should probably go ahead and do a command line rebuild if your OS and docker are recent versions.
Verson is 15.
It seems things are a lot better after I ran the vaccuum command.
Posting works fine and seems to be fast, but when admin try clicking user profiles, go into their profiles, it still 502’s, time out it seems like?
Is there something I can do to speed up that portion of the db?