Skip to content

connector: keep contact search bounded and stop it when the request is canceled - #296

Merged
highesttt merged 1 commit into
mainfrom
indent/line-fast-contact-search
Oct 29, 2026
Merged

highesttt merged 1 commit into
mainfrom
indent/line-fast-contact-search

Conversation

@indent

@indent indent Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Production logs over 24 h: search_users p90 is 116 s and p99 819 s. Six accounts had searches over 10 s; for one, the median search took 182 s and the slowest 875 s. That account also logged about 6.7k Failed to update ghost in database after updating info: context canceled errors and 4.6k avatar timeouts in 35 minutes, all from search requests the client had already abandoned.

Cause: SearchUsers already gets every contact from the batched GetContactsV2, but it then looked each match up again through GetUserInfo, one network call per contact with a BuddyService fallback. It returned every match, and it kept going after the request context was canceled. The provisioning API then syncs each result's ghost, one after another. GetAvatar ignored the context, so every avatar download kept running for up to 10 s after cancellation. It also uploaded non-200 bodies as avatars.

Change:

  • Cache the contacts from the batch lookup.
  • Cap name matches at 20, the limit the user-ID path already used.
  • Stop between batches once the context is done, in both search and the contact list.
  • Make GetAvatar use the request context and reject non-200 responses.

View in Indent
Tag @indent to continue the conversation here.

…s canceled

SearchUsers looked up every matching contact again one by one, returned
every match, and kept going after the client went away. The provisioning
API then synced each result's ghost, downloading avatars with a client
that ignored the request context, so a short query on a large contact
list ran for minutes.

Cache the contacts from the batch lookup, cap name matches at 20, stop
between batches once the context is done, and make avatar downloads use
the request context and reject non-200 responses.
@indent indent Bot added the to be tested label Oct 29, 2026
@indent

indent Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Issues

No issues found.

CI Checks

All CI checks passed on 60aeabc.

Review agents

Select any unchecked box below to run or rerun that agent.

Passed (1)
  • Indent Review Agent · No issues found in the contact search changes.
Full results

Indent Review Agent

  • Summary: No issues found in the contact search changes.
  • Last ran on commit: 60aeabcd
  • Latest result
    {
      "summary": "No issues found in the contact search changes.",
      "findings": []
    }

@iFixRobots
iFixRobots requested a review from highesttt October 29, 2026 11:01
@highesttt
highesttt merged commit 45a48b9 into main Oct 29, 2026
9 checks passed
@highesttt
highesttt deleted the indent/line-fast-contact-search branch October 29, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants