Skip to content

fix(api): store usernameToLower on skins so name lookups hit the cache - #1011

Open
ugcodrr wants to merge 4 commits into
mainfrom
fix/skin-name-lookup
Open

ugcodrr wants to merge 4 commits into
mainfrom
fix/skin-name-lookup

Conversation

@ugcodrr

@ugcodrr ugcodrr commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Description: Skin lookups by name query usernameToLower, but skins never stored it, so every name lookup scanned the skins collection and went back to Mojang.

  1. A cached name lookup takes about 0.5 ms instead of 587 ms and two Mojang calls.
  2. After a rename, a name lookup takes the newest skin with that name, and never falls back to the old owner's skin when Mojang fails.

#1014 is stacked on this PR. Merge order for the perf PRs is in #1002.

Testing: request /skin/textures?player=<name> twice. The second answer comes from the database.

getSkin has looked skins up by usernameToLower since #639, but the Skin
schema never had that field. Every lookup by name scanned the whole skins
collection, found nothing, and asked Mojang twice.

Skins now store usernameToLower, with an index. A name lookup takes the
most recently refreshed skin with that name, since an old owner's skin can
still carry a name after a rename. When the session server fails, the
cached skin is only used if it belongs to the uuid Mojang gave for the
name, so a name never falls back to its old owner's skin.

Skins saved before this change have no usernameToLower until they are
saved again or backfilled. Until then their name lookups go to Mojang,
as they do today.
@vercel

vercel Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
statsify Ignored Ignored Nov 5, 2026 8:18am UTC

@ugcodrr
ugcodrr added this pull request to stack #1064 October 31, 2026 21:11
@vercel

vercel Bot commented Nov 3, 2026

Copy link
Copy Markdown

Deployment failed for project statsify with the following error:

Too many requests - try again in 5 minutes (more than 60, code: "api-deployments-flood").

Learn More: https://vercel.com/docs/limits#rate-limits

ugcodrr added a commit that referenced this pull request Nov 5, 2026

This branch had an error being deployed

1 failed (outdated) deployment
Preview — 9e2c0b4c Deployed Oct 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant