Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer all stat increments to a job #17

Open
wants to merge 1 commit into
base: REL1_39
Choose a base branch
from

Conversation

mszabo-wikia
Copy link
Contributor

Cheevos currently attempts to perform all stat increments in a shutdown function, enqueueing a job if this fails. This can result in excessive load on the backing service as some stats are updated on e.g. every registered user PV on GP wikis, which can in turn also overload the UCP process pool due to the synchronous update.

So, always defer these stat increments to a job instead, for better concurrency control and reduced impact on user-facing process pools.

@@ -72,29 +73,13 @@ public function increment( string $stat, int $delta, UserIdentity $user, array $
}

private function doIncrements() {
// Attempt to do it NOW. If we get an error, fall back to the SyncService job.
Copy link

@rnix-fandom rnix-fandom Jun 28, 2024

Choose a reason for hiding this comment

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

for posterity: the intent of this was to make sure the stats for a page edit was processed in time for the page view immediately afterwards to show the toast notifications for any achievements earned. otherwise it was kinda weird for a first-time editor to edit a page and then at some indeterminate time later when they next made a page view get that toast. but among all the jank in the current Fandom ™️ first time editor experience, this is not as huge a deal as compared to what it was on Gamepedia.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I was to guess this might already have been broken, since this runs in a shutdown function, by which time the user will have already been redirected after a successful edit since FPM will have flushed the response due to MediaWiki running fastcgi_finish_request as part of its request termination logic.

Choose a reason for hiding this comment

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

Yeah, I agree, it was probably always race-y, and just got less likely to do the intended behavior over time as more stuff was being done in shutdown and as external services became more numerous.

Cheevos currently attempts to perform all stat increments in a shutdown
function, enqueueing a job if this fails. This can result in excessive
load on the backing service as some stats are updated on e.g. every
registered user PV on GP wikis, which can in turn also overload the UCP
process pool due to the synchronous update.

So, always defer these stat increments to a job instead, for better
concurrency control and reduced impact on user-facing process pools.
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.

3 participants