Fix content.sync cartesian explosion and gateway timeout

- Add .AsSplitQuery() to ContentSyncHandler to prevent the cartesian
  product join caused by two collection .Include()s (Assets + AnimationBindings).
  EF was executing a single JOIN that multiplied result rows per card,
  causing replies to arrive 10+ seconds late and gateway timeouts.
- Bump Gateway__RemoteDispatchTimeoutMs from 10000 → 15000ms in configmap
  to give worker pods headroom on cold starts (EF model compilation +
  first DB query can take 3-5 seconds on a fresh pod).

NOTE: restart gateway pods after deploying to pick up the new timeout value:
  kubectl rollout restart deployment/sor-gateway -n stone-server

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-02-28 19:05:32 -05:00
co-authored by Claude Happy
parent 7150afa42e
commit 502f1c16f6
2 changed files with 4 additions and 1 deletions
@@ -36,12 +36,15 @@ internal sealed class ContentSyncHandler : IMessageHandler
var pageSize = Math.Clamp(req.PageSize, 1, 500);
// Fetch one extra to detect HasMore without an additional COUNT query.
// AsSplitQuery avoids the cartesian product caused by two collection Includes.
// Without it EF emits a single JOIN that crosses Assets × AnimationBindings per card.
var cards = await _catalogDb.CardDefinitions
.Include(c => c.Assets)
.Include(c => c.AnimationBindings)
.Where(c => c.DefinitionVersion > req.SinceVersion)
.OrderBy(c => c.DefinitionVersion)
.Take(pageSize + 1)
.AsSplitQuery()
.ToListAsync(ct);
var hasMore = cards.Count > pageSize;