Getting an error 502 trying to use the anonymize user feature

AI-generated summary

A user, skozz, reports a 502 error when using the anonymize user feature in Discourse, running version v1.8.0.beta4 on Docker via DigitalOcean. The issue appears to stem from the user having a large number of posts (479) and private messages, causing timeouts during the anonymization process. Other users, like JagWaugh, confirm similar issues on low-memory systems, such as AWS t2.micro instances. Sam suggests that the anonymize and re-assign ownership tasks should be moved to background jobs to prevent timeouts, a change that would require significant development effort. Neil confirms the feature works but acknowledges the need for background processing. He provides a Rails console command to manually anonymize a user: UserAnonymizer.make_anonymous(User.find_by_username('anon_this_user'), User.find_by_username('who_is_doing_it')). Skozz confirms the workaround works and requests improved Spanish translation for the anonymized username format, offering to help with localization. JagWaugh concludes by noting that increasing RAM to 2GB resolved stability issues on his system. skozz, sam, neil, JagWaugh, JagWaugh

I’m receiving a 502 error using the anonymize user feature

I’m running Discourse over DigitalOcean + Docker (using the DO application installer)

Thank you!

@neil is this feature still working?

Yes it still works. What else can you tell us about your install @skozz? Do you get bad gateway errors for other operations?

One possibility is that the user has SOOOO many records that this thing times out mid job.

I can attest to that…

Is the same conclusion that I just reach :thinking: The user has 479 psots. 140 private messages

Yup, of course. It’s a docker from the DigitalOcean installer, v1.8.0.beta4 +7 at the moment of this reply. And no, there no have more gateway errors.

Thank you guys for your time

Is there some way to throttle such admin tasks?

On my test machine (AWS t2.micro with 1 GB ram) when I do a rake users:change_post_ownership on an account with more than about 100 posts the task loses communication and bombs out and I end up restarting the whole box.

Or is my docker broken? (other than apt-get update/upgrade I haven’t done anything criminal)

Both this task (anonymize) and re-assign ownership need to be re-written so they kick off a background job to do the actual work and then simply make quick web calls to check on progress.

Unfortunately there is a day or 2 of work in making this kind of change. But we should get it on someone’s list.

In the meantime @neil can you provide CLI instructions on how to anonymize an account by entering the container?

Yeah this should definitely be done in a background job. Doesn’t look hard to do that, although error reports will need to be sent via PM if something goes wrong.

From rails console, you can anonymize like this:

UserAnonymizer.make_anonymous(
  User.find_by_username('anon_this_user'),
  User.find_by_username('who_is_doing_it')
)

Works! thank you! btw, if you will address the issue could be awesome if you can improve the translation. In my case, “anon123456” could be “anónimo123456” (Spanish).

Of course, if you let me know when and where (branch) you will address the issue, I can do the localisation part (I’m starting developing things on Discourse).

Just to invoke closure on my issue. Once I changed my VM to 2GB ram rake tasks became a LOT more stable (as did everything else).