Skip to content

Add AzerothCore cluster service integration#37

Draft
VG-prog wants to merge 11 commits into
walkline:masterfrom
VG-prog:vg/tc9-cluster-integration-review
Draft

Add AzerothCore cluster service integration#37
VG-prog wants to merge 11 commits into
walkline:masterfrom
VG-prog:vg/tc9-cluster-integration-review

Conversation

@VG-prog

@VG-prog VG-prog commented May 22, 2026

Copy link
Copy Markdown

This replaces the previous draft PR split (#27-#36).

Those drafts were opened from stacked branches while targeting master, which made the GitHub diffs misleading: each PR included earlier slices and a lot of unrelated-looking overlap. This PR intentionally presents the current ToCloud9 side of the AzerothCore cluster integration as one honest review surface instead of pretending the stacked branches are independent.

What this adds

  • Shared cluster contracts for realm-aware character, chat, group, guild, matchmaking, registry, and worldserver coordination, including generated protobuf code.
  • Service-discovery and readiness hardening for game servers, gateways, and matchmaking, including degraded world-loop handling that preserves ownership but drains new player placement until recovery.
  • Gateway-side cluster routing and client presentation paths for sessions, redirects, chat/channel packets, social data, group frames, guild packets, guild bank interactions, LFG, arena teams, and player-state extraction.
  • Character, chat, mail, and social-service updates needed for realm-aware and clustered operation.
  • Distributed group state, including roster identity, live member-state routing, ready checks, raid/subgroup flags, and cleanup behavior.
  • Distributed guild and charter flows, plus transactional guild-bank coordination.
  • Crossrealm LFG, battleground, and arena coordination, including materialization and route ownership support.
  • Game-server sidecar APIs needed by the AzerothCore integration.
  • Auth and character database migrations for the new cluster persistence requirements.

Review notes

The implementation is large because the pieces share protobuf contracts, generated clients, gateway listeners, service events, sidecar calls, and database state. Splitting this into independent PRs against master is not currently truthful unless the earlier foundation PRs are merged first and later PRs retarget those merged bases.

The main intention here is to give a correct review target for the current integration state. If you prefer a sequential merge plan, the safe order is roughly:

  1. contracts/generated/shared helpers;
  2. discovery/readiness;
  3. gateway routing and packet presentation;
  4. character/chat/mail/social services;
  5. group state;
  6. guild and guild bank;
  7. matchmaking/LFG/BG/arena;
  8. sidecar APIs;
  9. SQL migrations.

That sequence should be created as a real stacked series only after each base exists in the upstream repository or in an agreed upstream integration branch.

Validation

Run on the cleaned branch:

git diff --check upstream/master..vg/tc9-cluster-services
env GOCACHE=/tmp/tc9-go-build GOFLAGS=-buildvcs=false go build ./...
env GOCACHE=/tmp/tc9-go-build GOFLAGS=-buildvcs=false make install

All three passed locally.

VG-prog added 11 commits May 22, 2026 21:49
Add the shared protobuf, generated runtime code, events, GUID helpers, auth identity helpers, and configuration contracts used by clustered gateway, registry, group, guild, matchmaking, and sidecar flows.

Tests, local tooling, and broad documentation are intentionally excluded from this upstream-focused scope.
Wire service discovery, map readiness, stale-safe health and metrics observers, degraded game-server health handling, gateway-scoped cleanup, and shared GUID allocation support.

Registry and health code now distinguish world-loop degraded state from process or transport death while preserving live map ownership.
Keep world-loop degraded game servers registered for ownership and existing lookups, but mark them as non-admitting so new player placement skips them. Clear the drain state on successful health recovery and fall back to healthy all-map nodes when an assigned owner is degraded.
Route gateway sessions through cluster-aware worldserver selection, native transport handoff, bounded retry/backoff, cross-service event listeners, and client-facing packet rendering for social, group, guild, guild bank, LFG, battleground, arena, mail, channel, and player-state flows.
Extend character, chat, and mail services for clustered realm identity, Real ID/account lookups, channel membership and moderation, crossrealm whisper policy, online-state broadcasts, and arena-team persistence used by gateway routing.
Add clustered group authority for realm-scoped membership, native LFG materialized groups, member-state freshness, latest-state catch-up, receiver-aware fanout, offline cleanup, debug tracing, and persistent group identity support.
Add realm-scoped guild service routing, charter offer/sign/query/signature handling, native petition persistence, guild cache lifecycle, gateway-facing events, and debug logging for same-realm clustered guild workflows.
Add guildserver-owned same-realm guild bank item, money, tab, log, text, split, merge, withdraw-limit, rollback, and idempotency helpers backed by direct MySQL transactions and guidserver item allocation.
Extend matchmaking and mysqlreverseproxy for crossrealm LFG proposal materialization, persistent instance routes, battleground owner placement, arena-team persistence and rated-result handling, character-state listeners, and route-aware SQL interception.
Extend the libsidecar C ABI and Go bridge with grouped member-state events, guild and LFG RPCs, arena-team and item APIs, monitoring/readiness behavior, config loading, and consumer handlers required by the clustered AzerothCore integration.
Add auth and character database migrations for Real ID friends, crossrealm group identity, LFG route persistence, stable petition IDs, and guild bank idempotency/locking changes required by clustered services.

@walkline walkline left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I will review it in several sessions. This is the first one.

@@ -0,0 +1,66 @@
SET @tc9_has_petition_id := (

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This migration is not needed.

@@ -0,0 +1 @@
DROP TABLE IF EXISTS `tc9_guild_bank_lock`;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one not needed as well.

Comment on lines +33 to +36
B = fixedLittleEndianBytes(s._B, 32)
g = bigIntToBytesLittleEndian(_g)
N = fixedLittleEndianBytes(bigIntToBytesLittleEndian(_N), 32)
_s = fixedLittleEndianBytes(s._s, 32)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering what was wrong with previous SRP implementation?

Comment on lines -61 to -63
if err != nil {
return nil, err
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to explicitly show the error rather than hide the issue.


func (s *AuthSession) write(writer io.Writer, v ...interface{}) error {
var err error
packet := new(bytes.Buffer)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why are we using an additional buffer instead of writing directly to the writer?

Comment on lines +59 to +64
authDB, err := sql.Open("mysql", conf.AuthDBConnection)
if err != nil {
log.Fatal().Err(err).Msg("can't connect to auth db")
}
defer authDB.Close()
configureDBConn(authDB)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I don't know if we want the auth DB in charserver. I understand that it's required for Real ID, but I don't see this feature as super important. Maybe we could make it optional and hide it behind config?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, ill approach it!

Comment on lines +2 to +3
account_id_low INT UNSIGNED NOT NULL,
account_id_high INT UNSIGNED NOT NULL,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is low and high id? Why its required here?


team := ArenaTeamDetails{}
err = db.QueryRowContext(ctx, `
SELECT arenaTeamId, name, captainGuid, type, rating, weekGames, weekWins, seasonGames, seasonWins, `+"`rank`"+`, backgroundColor, emblemStyle, emblemColor, borderStyle, borderColor

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use prepared statements in this repo, like we do in other places?


lockName := fmt.Sprintf("tc9_arena_team_create:%d", request.RealmID)
var locked int
if err := db.QueryRowContext(ctx, "SELECT GET_LOCK(?, 5)", lockName).Scan(&locked); err != nil {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid locking when possible. I assume it's there to make sure we don't create the same team twice. I'm not sure if that's even possible, but theoretically, if it is, then it's probably better to add a uniqueness constraint to the name field, for example. Then I think we can remove this lock.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants