Skip to content

fix(online): follow up on the merged online pull requests - #2488

Open
houko wants to merge 5 commits into
mainfrom
fix/followup-online-3
Open

houko wants to merge 5 commits into
mainfrom
fix/followup-online-3

Conversation

@houko

@houko houko commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Follow-up review of the online pull requests merge/2387 landed without CI: the gameserver matchmaking, results and async jobs PRs, the self-hosted leaderboard tournament, operator and SQL store PRs, and the liveops portal, crash fingerprint and account client PRs. Each PR was compared line by line with current main and read for correctness.

#2218 feat(gameserver): add matchmaking ticket queries

Landed intact, but Matchmaker.Expire (added by #2339 on top) iterated and deleted from the queue without the mutex this PR introduced, so it raced with Enqueue and Match. This PR splits it into a locked Expire and an internal expireLocked used by Match, documents the new Ticket fields and TermKind constants, and moves defaultRule's comment back onto it (the merge left it on cloneStrings). The issue's YAML queue file form (#1689) was not implemented; #1689 was closed by another PR.

#2230 feat(gameserver): commit match results idempotently

Overwritten by the older #2086 in the merge. Main compared a retry only by grant counts, so a different payload for a committed match was accepted as an idempotent retry; record bytes were kept by reference; empty keys were accepted; and the score outbox (ScoreSink, DeliverScores, PendingScores), the Record, Balance and BestScore readers, three of the four tests and the guide section were gone. This PR restores #2230's results.go and results_test.go with main's doc comments, and the guide section in both languages, which now says plainly that the in-memory outbox does not survive a crash.

#2339 feat(gameserver): add matchmaking ticket expiry and teams

The merge dropped the Enqueue check that refuses a party larger than one team or a Teams count that does not divide RoomSize (an acceptance item of #1322). splitTicketTeams also skipped a party that fit no team, so a formed match could leave players out of Matchup.Teams (three pairs for two teams of three). This PR restores the check; the split now reports failure, the default rule adds a party only when the teams can still hold it, and Match does not form a room a custom Rule returns that cannot be split. Tests cover the oversize party, the unsplittable room and concurrent Expire.

#2340 feat(gameserver): add bounded async match jobs

OK. Only the comment wrapping of PendingTimeout and MaxPending changed in the merge. Serial and Go now use ensureJobs' return value instead of re-reading Match.jobs outside its mutex.

#2081 feat(leaderboard): add tournament lifecycle core

Landed intact but buggy: scores and attempts were one map for the whole tournament, so MaxAttempts never reset between rounds and each round settled with every earlier round's scores; EndRound only looked at the round just before now, so a late call skipped rounds, a last round cut short by End never settled, and a tournament with no End settled its only round on the first call; OnRoundEnd ran under the lock, so a callback calling Entrants deadlocked. This PR keeps per-round state, settles every ended round once and in order outside the lock, and refuses a submission to a settled round. It still does not meet #1682's acceptance (config format, service and HTTP routes, restart-safe OnRoundEnd).

#2085 feat(leaderboard): add operators and monthly periods / #2232 feat(leaderboard): add score operators and metadata

Two attempts at #1681. The merge kept #2232's service code but #2085's config validation and test: the checks refusing an unknown operator, an out-of-range metadataMaxBytes and a set, increment or decrement board without validation: signed were gone, so a typo behaved as set and any client could submit increments, and the remaining test asserted that an unsigned increment board loads. Both PRs' guide sections were dropped. This PR restores #2232's validation, test file and guide section (both languages, with the HTTP fields), and updates the note in place. A server proof still signs only board, account and score, so subscore and metadata stay client-controlled on signed boards; the guide and note now say so.

#2092 / #2227 feat(leaderboard): add SQLite and Postgres stores

Two near-identical attempts at #1680. The code landed once; #2227's tie and stale retry test and both guide sections were dropped. The store also ignored #2232's fields: it persisted neither subscore nor metadata, and kept the higher score on every board, so a set or decrement board read back an older score after a restart. This PR adds schema version 2 (subscore and metadata columns, migrating a version 1 database), makes Save follow the board's operator and subscore, restores the test, adds tests for the new columns and the migration, and restores the guide sections and the leaderboardd flags. #1680 itself remains open: ranking is still in memory.

#2095 feat(liveops): add web portal ad breaks

Rewarded granted a reward that an SDK reported after the break had timed out, contrary to its contract. This PR refuses it when the call's context has ended and adds a test, plus doc comments on the provider constants, hooks and ErrPortalTimeout.

#2116 feat(liveops): add crash report fingerprints

OK. Main's Fingerprint is a later revision of this PR's (with a sha256: prefix and argument stripping); the docs match it.

#2120 feat(liveops): add game-side accounts client

The guide sections in accounts.md were dropped, and the PR carried two notes and two changelog fragments for the same change, one of them a placeholder. LinkIdentity returned an AccountConflict without its provider, and a refresh finishing after SignOut wrote the old token and account ID back. This PR fixes both with tests, restores one merged guide section in both languages, and removes the duplicate note and fragment.

Verification

  • go tool nsgo test ./pkg/online/gameserver/... ./pkg/online/leaderboard/... ./pkg/online/liveops/... ./cmd/leaderboardd/... (and -race on the touched tests)
  • go tool nsgo check on each of those packages
  • go tool nsgo test ./internal/repocheck/...
  • go run ./changelog check in tools, bun run verify-notes

Screenshots: None

…ison and score outbox

The merge of #2086 over #2230 put back the first ResultsBackend: a retry was compared by grant counts only, so a different payload for a committed match was accepted as a no-op retry; record values were kept by reference; empty keys were accepted; and the score outbox, ScoreSink, DeliverScores and the Record, Balance and BestScore readers were gone along with their tests and the gameserver guide section. This restores #2230's version with the doc comments main added since, and documents that the in-memory outbox does not survive a crash.
Expire ran without the queue lock that #2218 added, racing with Enqueue and Match. The merge of #2218 and #2339 dropped the Enqueue check that refuses a party larger than one team, and the Ticket.Deadline comment. splitTicketTeams skipped a party that fit no team, so Matchup.Teams could leave players out of a formed match; it now reports failure, the default rule adds a party only when the teams can still hold it, and Match does not form a room a custom rule returns that cannot be split. Also documents the ticket fields and term kinds, moves defaultRule's comment back onto it, and uses ensureJobs' result instead of re-reading Match.jobs.
…nd metadata in SQL

The merge of #2085 over #2232 dropped the Board checks that refuse an unknown operator, an out-of-range metadataMaxBytes and a set, increment or decrement board without signed validation, so a typo acted as set and any client could submit increments; it also put back #2085's test that expected an unsigned increment board to load. The SQL store from #2092 and #2227 stored neither the subscore nor the metadata and kept the higher score on every board, so after a restart a set or decrement board read back an older score. Schema version 2 adds both columns, migrating a version 1 database, and Save follows the board's operator and subscore.

The guide sections #2232, #2092 and #2227 added (operators and monthly periods, SQL persistence, the leaderboardd store flags) were lost in the merge too; they are restored in both languages with the HTTP fields the operators added, and #2227's tie and stale retry test is back.
#2081's Tournament kept one score and attempt map for the whole tournament, so MaxAttempts never reset between rounds and every round settled with the scores of all earlier ones. EndRound only looked at the round just before now, so a late call skipped rounds, a last round that End cut short was never settled, and a tournament with no End and no Duration settled its only round on the first call. OnRoundEnd also ran under the lock, deadlocking a callback that called Entrants. Rounds now keep their own state, EndRound settles every ended round in order and calls OnRoundEnd after unlocking, and a submission to a settled round is refused.
Portal.Rewarded granted a reward an SDK reported after the break's context had already timed out, against its contract that timeouts never grant. Account.LinkIdentity returned an AccountConflict with no provider, a refresh that finished after SignOut wrote the old account's token and ID back, and the token request accepted an empty URL. The game-side client section #2120 added to the accounts guide was lost in the merge and is restored in both languages, the placeholder note and changelog fragment that duplicated #2120's own are removed, and the portal constants, hooks and errors get doc comments.
@github-actions github-actions Bot added size/XL bug Something isn't working documentation Improvements or additions to documentation area/agents pkg/online and removed bug Something isn't working labels Nov 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/agents documentation Improvements or additions to documentation pkg/online size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant