Max new topic per day with negative wait seconds

AI-generated summary

A community on Discourse v3.1.0.beta4 experienced an issue where non-admin users were unable to create new topics, receiving a rate limit error with a negative wait_seconds value. The problem occurred after importing data and setting the maximum new topics per day to 0, which caused the system to incorrectly calculate the wait time. JammyDodger replicated the issue by setting the limit to 0, confirming it was the root cause. Jonathan_Poyer resolved it by setting the limit to the maximum allowed value, 2000000000. pfaffman suggested that setting the limit to 0 should be disallowed to prevent this bug. Jagster asked about appropriate values for users who don’t want to use the limit, and Jonathan_Poyer confirmed the workaround.

We’ve just opened our community to all our internal customers :tada:.
Before doing so, we have imported (through API) lots of data two weeks ago with reassigned ownership of posts/topics and setting the right date. For our entire community, the last topic was created 21h ago and not by that person.

All our users are TL3 or above.
We are on v3.1.0.beta4.

Our first user (who had created their account 18days ago) is now trying to post a new topic. They are however facing a strange issue:

"errors":["You’ve reached the maximum new topics allowed per day. You can create more new topics in a few seconds."],
"error_type":"rate_limit",
"extras":{"wait_seconds":-1683792363,"time_left":"a few seconds"}

The wait_seconds is negative (and going even more down for each attempt) and that puzzles me. Is there something we need to reset somewhere?

We have set all rate limits to 0.

That’s strange Indeed.

You’re self hosted? It’s a standard install?

Does this affect all users or just this one?

There are some rake tasks and some model methods with “ensure_consistency” in their names. You might try those.

It doesn’t seem likely that it’s a bug you can replicate.

Thanks Jay!

It is a self-hosted standard install indeed and affects all non-admin users.

I do not have access to the container but will ask the person who does to check some of the rake tasks.

I’ve had a quick test and I think I can replicate this if I set the max topics per day to 0 and try and create a topic with a non-admin user:

Is that worth a check?

That is the solution! Thank you @JammyDodger!

So if an admin doesn’t want to use that limit then value like 86400 is right solution?

I have ended up using the max allowed value which is 2000000000

Nice work, @JammyDodger!

Maybe move this to Contribute > Bug and disallow setting that to 0.

Shows what I know!