502 errors when splitting topic, moving or renaming categories

Hi.
I’ve also posted here: Moving posts returns 502 bad gateway
but it seems that the error occurs in other contexts. I can’t rename a category:

Js console:
image

Same in safe-mode (I don’t have custom themes or plugins anyway, except data-explorer), version 2.6.0.beta2
My server is on Ubuntu 18, has 4 vCPU, 8 GB ram, 160 GB disk space.

2 Likes

Does it take a long time for the error to surface? I think you’re running into a timeout because of a heavy query.

1 Like

20-30 seconds maybe? Also, it doesn’t happen when renaming other categories. :thinking:

edit: also happens on my development forum (fairly strong computer with a ubuntu subsystem).

re-edit:

  1. splits by smaller batches seem to work. So Discourse doesn’t like to move more than 3000 topics, even of a more powerful server (I upscaled to a 16 vCPU / 32 GB). So I guess that this issue is different from renaming my categories. I still couldn’t rename the category.

  2. I created a new category B (which I can rename at will), moved all the topics from the category A (which I can’t rename) to the category B: then I can’t rename category B anymore, and I can rename the category A.
    I tried to rename my categories, choosing a category with more posts in it each time. Category with more content (more posts, larger topics) seems to take more time to be renamed.

There are 2 categories that I can’t rename (seems to take too much time indeed…):
image

I can rename Public profile messages, which contain only topics without replies.

30 seconds is the nginx timeout, so that makes sense. It just needs more time than that.
If I were you I would try this from a rails console.

I thought doing it this way, but I wasn’t sure it would be safe: I wonder why it would take that much time just to rename a category title in Discourse :thinking:
Does it need to check stuff I don’t think about?

Apparently :slight_smile:
I guess it might be recalculating some stats. What you could do is connect to Postgres and run something like

SELECT pid, age(query_start, clock_timestamp()), usename, query 
FROM pg_stat_activity 
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' 
ORDER BY query_start desc;

to see what it is what is taking so long.

Thank you!
I’m not familiar with that though. Should I run this query while Discourse is trying to change the category name?

Yes, it will show you the currently running queries, so you should run it while waiting. You have 30 seconds :wink:

2 Likes

I ran the query about 10 seconds after trying to change the category name, and here’s what it returns:

I see nothing weird? :thinking:

I see a very trivial query (UPDATE categories...) that looks like it is taking up 13 seconds already…
What happens if you run it manually?

EDIT if this is an imported forum, it might help to backup and then restore it.

Since I have the same issue on my development install on my home computer, I tried on my dev forum.

I tried to change the category name through Discourse interface. The error I’ve shown in my first post occured and my ram was filled up:
image

Your query shows:

I tried updating from the rails console,
Tried these two commands:

ActiveRecord::Base.connection.execute("UPDATE categories SET name = 'General Discussion', topic_template = '', sort_order = '', default_view = '', read_only_banner = '', name_lower = 'general_discussion', updated_at = '2020-09-16 13:36:50.014192' WHERE categories.id = 21")
Category.where(id: 21).update(name: "General")

Both worked like a charm.

That’s… interesting… :thinking:

Update: I tried to rename a category on my other, live forum (different data/server/os/etc, but same Discourse version).

Changing a category name is slow (~10s). I tried multiple times and also encountered a 502 error once.

I feel like this is an issue from Discourse maybe related to a recent update? :thinking:
Both forums use 2.6.0.beta2.

Can someone try to change a category name (a category with thousands, or tens of thousands topics) on their own forum, with the same Discours version to see if it is slow or generates a 502?

2 Likes

Did renaming categories with a large number of topics work fast for you in previous Discourse version?

I don’t remember having a 502 error on my previous forum (which was also imported), but I haven’t renamed a category since the import 3 years ago. I don’t remember if renaming a category was slow.
As for my new, larger forum, it was imported on the Discourse’s version I’m mentioning so I can’t compare with an older version.

1 Like