Use replica for admin PvP stats reads#188
Open
Yehonal wants to merge 1 commit into
Open
Conversation
Move heavy PvP stats admin-panel read queries onto a dedicated replica PDO connection while leaving reward/account writes on the normal path. Also remove duplicated executeQuery calls in ACoreServices read helpers.
Contributor
There was a problem hiding this comment.
Pull request overview
Routes the admin-panel PvP rewards/statistics read queries through a dedicated replica MySQL connection to reduce load on the primary (write-capable) AzerothCore DB connections, while also cleaning up redundant DBAL statement execution in read helpers.
Changes:
- Added a PDO-based helper in
SettingsControllerto run PvP stats reads against a replica connection configured via environment variables. - Switched the PvP rewards/statistics queries to use the replica query helper instead of the Doctrine character DB connection.
- Removed redundant duplicate
executeQuery()calls in severalACoreServicesread helper methods.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/acore-wp-plugin/src/Manager/ACoreServices.php |
Removes redundant extra executeQuery() calls so read helpers only execute once per request. |
src/acore-wp-plugin/src/Components/AdminPanel/SettingsController.php |
Introduces a replica PDO connection + helper and routes PvP stats reads through it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+25
to
+44
| private function getPvpStatsReplicaPdo(): \PDO { | ||
| return new \PDO( | ||
| 'mysql:host=' . getenv('PVPSTATS_REPLICA_HOST') . ';port=' . getenv('PVPSTATS_REPLICA_PORT') . ';dbname=' . getenv('PVPSTATS_REPLICA_DB') . ';charset=utf8mb4', | ||
| getenv('PVPSTATS_REPLICA_USER'), | ||
| getenv('PVPSTATS_REPLICA_PASSWORD'), | ||
| [ | ||
| \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, | ||
| \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC, | ||
| ] | ||
| ); | ||
| } | ||
|
|
||
| private function runPvpStatsReplicaQuery(string $query, array $params): array { | ||
| $stmt = $this->getPvpStatsReplicaPdo()->prepare($query); | ||
| foreach ($params as $key => $value) { | ||
| $stmt->bindValue(':' . $key, $value); | ||
| } | ||
| $stmt->execute(); | ||
| return $stmt->fetchAll(); | ||
| } |
Comment on lines
+25
to
+35
| private function getPvpStatsReplicaPdo(): \PDO { | ||
| return new \PDO( | ||
| 'mysql:host=' . getenv('PVPSTATS_REPLICA_HOST') . ';port=' . getenv('PVPSTATS_REPLICA_PORT') . ';dbname=' . getenv('PVPSTATS_REPLICA_DB') . ';charset=utf8mb4', | ||
| getenv('PVPSTATS_REPLICA_USER'), | ||
| getenv('PVPSTATS_REPLICA_PASSWORD'), | ||
| [ | ||
| \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, | ||
| \PDO::ATTR_DEFAULT_FETCH_MODE => \PDO::FETCH_ASSOC, | ||
| ] | ||
| ); | ||
| } |
Helias
reviewed
May 19, 2026
| $conn = $this->getAccountEm()->getConnection(); | ||
| $stmt = $conn->prepare($query); | ||
| $stmt->bindValue(1, $user->get("user_login")); | ||
| $stmt->executeQuery(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation