502 error - chatables

Ok, I figured it out :sweat_smile:

My first fix only addressed part of the issue :man_facepalming: There was another inefficient database query happening when searching for groups in the chat filter. Depending on which groups matched your search term, the query could take a very long time to complete – sometimes exceeding our request timeout.

Interestingly, this only affected “regular” users and not “admins”, hence why I wasn’t able to reproduce myself :thinking:

When searching for groups, results are returned alphabetically. Admins can see all groups, so their first 10 results for “L” were small groups starting with ‘a’ (like “ai-personas” and other non-public groups). Regular users have more limited visibility, so their results included the large trust level groups :grimacing:, which is what caused the slow query.

Regular user sees:

  • trust_level_0: 62,506 users
  • trust_level_1: 34,494 users
  • trust_level_2: 4,727 users
  • trust_level_3: 39 users
  • trust_level_4: 13 users
  • plus some smaller groups

Total: ~102,000 users to load :collision:

Admin sees:

  • a*****: 4 users
  • a*****: 76 users
  • a*****: 0 users
  • a*****: 2 users
  • ai-personas: 138 users
  • etc.

Total: ~240 users to load :relieved:

1 Like