Page MenuHomePhabricator

CentralAuth: Include global edit status in GetSecurityLogContext
Closed, ResolvedPublic

Description

Summary

Record whether a user has any global edits in the GetSecurityLogContext hook, so this information is available for filtering in Logstash.

Technical notes

A previous attempt (630fa7c282bb1687a44e3fd8778a6f3fbb9e7df7) was reverted because it caused deadlocks during login (T416637). CentralAuthEditCounter::getCount() can fall through to the primary DB and perform INSERT+UPDATE on global_edit_count when no row exists for a user. This write path caused deadlocks when called from the GetSecurityLogContext hook.

The fix adds a $readOnly parameter to getCount(). When true, only the replica DB is queried and null is returned if no row exists, avoiding any writes. The user_has_edits_global context field is only set when the count is available.

Acceptance criteria

  • user_global_edit_count is included in security log context when the global edit count row exists
  • No writes to the database occur during the GetSecurityLogContext hook

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change #1242807 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/CentralAuth@master] CentralAuthEditCounter: Add $readOnly parameter to getCount()

https://gerrit.wikimedia.org/r/1242807

Change #1242808 had a related patch set uploaded (by Kosta Harlan; author: Kosta Harlan):

[mediawiki/extensions/CentralAuth@master] GetSecurityLogContext: Record if the user has any edits

https://gerrit.wikimedia.org/r/1242808

Change #1242807 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] CentralAuthEditCounter: Add getCountIfInitialized() method

https://gerrit.wikimedia.org/r/1242807

Change #1242808 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] GetSecurityLogContext: Record user's global edit count

https://gerrit.wikimedia.org/r/1242808

Dreamy_Jazz updated the task description. (Show Details)