zogstrip
(Régis HANOL)
29. Dezember 2025 um 17:43
5
Es gab eine fehlerhafte Abfrage, die verwendet wurde, um die Anzahl der Benutzer mit aktiviertem Chat im Chatgruppen-Serializer zurückzugeben, und diese dauerte für Ihr Konto etwa 30 Sekunden, was dem Timeout auf unserem Hosting entspricht (deshalb trat es „zufällig“ auf).
main ← fix-chatables-timeout
opened 05:40PM - 29 Dec 25 UTC
When searching for `chatables`, groups matching the search term are serialized. … The serializer was computing `chat_enabled_user_count` by loading **ALL** users from each group into memory and iterating through them in Ruby:
```ruby
object.human_users.count { |user| user.user_option&.chat_enabled }
```
On large sites, groups like `trust_level_0` can have tens of thousands of users. This caused serialization to be extremely slow, potentially hitting request timeouts and resulting in 502 errors.
The fix uses a SQL COUNT query instead, which completes in milliseconds. The result is also memoized since `can_chat` calls `chat_enabled_user_count` internally.
Ref: https://meta.discourse.org/t/392286
3 „Gefällt mir“