Page MenuHomePhabricator

prefUpdate schema contains multiple identical events for the same preference update
Closed, ResolvedPublic

Description

(Schema page for reference: https://meta.wikimedia.org/wiki/Schema:PrefUpdate )

I just happened upon this observation by @Halfak from February 2017:

I did some queries and this schema is obviously broken. It's common to see a "prefUpdate" show up multiple times for the exact same value with the same timestamp. So it's hard to know when a change actually took place and when it did not. So, I think I'll be declining this ticket [about using the PrefUpdate schema for a particular instrumentation for ORES].

Since the web team is currently relying on this schema (cf. T212516 , T211197), I checked if this is still an issue. There are indeed still lots of such duplicate events as of last month, although they seem to be focused on particular properties (compare also this list of the 200 most frequent properties in the schema overall):

SELECT event.property AS property, COUNT(*) AS duplicated_events
FROM (
  SELECT event, COUNT(*) AS copies
  FROM event.prefupdate 
  WHERE year = 2019 AND month = 2
  GROUP BY event
  HAVING copies > 1) AS events
GROUP BY event.property
ORDER BY property LIMIT 10000;
property	duplicated_events
cx	115
date	1
echo-subscriptions-email-article-linked	1
echo-subscriptions-email-edit-thank	1
echo-subscriptions-email-login-fail	1
echo-subscriptions-email-login-success	1
echo-subscriptions-email-mention	1
echo-subscriptions-email-oauth-owner	1
echo-subscriptions-email-page-review	1
echo-subscriptions-web-article-linked	2
echo-subscriptions-web-mention-failure	1
echo-subscriptions-web-mention-success	1
echo-subscriptions-web-reverted	1
editsectiononrightclick	1
enotifminoredits	1
enotifwatchlistpages	1
fileexporter	285
gender	1
lqt-watch-threads	32
lqtdisplaycount	266
lqtdisplaydepth	266
lqtnotifytalk	306
minordefault	68
php7	59
popups	1
prefershttps	9540
templatewizard-betafeature	3105
timecorrection	3
twocolconflict	192
uls-preferences	26
usecodemirror	6
visualeditor-betatempdisable	165
visualeditor-enable	705
visualeditor-findAndReplace-findText	13
visualeditor-findAndReplace-replaceText	6
visualeditor-newwikitext	3207
visualeditor-visualdiffpage	185
Time taken: 85.171 seconds, Fetched: 37 row(s)

QA steps

Verify that opt-in and out from Beta and AMC modes work properly on a mobile site. Also, please double check that saving user preferences works with, and without Javascript.

QA Results - Beta

ACStatusDetails
1T218835#6905829
2T218835#6905829

QA Results - Prod

ACStatusDetails
1T218835#6912461
2T218835#6912461

QA Results - Beta

ACStatusDetails
1T218835#6941076
2T218835#6941076

QA Results - Prod

ACStatusDetails
1T218835#6968753
2T218835#6968753

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

(Tagging this with Analytics considering general EL code stewardship and the current schema maintainer, although I honestly don't know who is in the best position to fix this.)

I used data from this schema in T216185. My experience was similar to what @Tbayer mentions in that some preferences appear to have issues with duplication, and some do not. In this case the echo-notifications-blacklist and email-blacklist preferences were affected. It also seems that the issue changed over time, in other words that some users logged lots of preference changes during certain periods, and not during others.

This schema has no owner and it's the owner who has to correct the instrumentation.
cc @jlinehan fyi

In T249386, I used prefupdate data to determine the opt-in and opt-out rate of the discussiontools-betaenable property. While reviewing the data, I found there were 100 duplicate events recorded for this property between March 31 and June 26th.

sdkim triaged this task as Medium priority.Sep 28 2020, 3:15 PM
sdkim moved this task from Inbox to Next on the Product-Data-Infrastructure board.

Product Infrastructure data as the new crowned owners of this schema will be reviewing and hoping to merge here soon.

SELECT
  year, month,
  CONCAT_WS(', ', COLLECT_SET(event.property)) AS properties_affected,
  COUNT(1) AS duplicated_events
FROM (
  SELECT year, month, event, COUNT(1) AS copies
  FROM event.prefupdate 
  WHERE year = 2020
  GROUP BY year, month, event
  HAVING copies > 1
) AS events
GROUP BY year, month
ORDER BY year, month
LIMIT 1000000;
yearmonthproperties_affectedduplicated_events
20206VectorSkinVersion, betafeatures-auto-enroll, discussiontools-betaenable, echo-notifications-blacklist, email-blacklist, growthexperiments-help-panel-tog-help-panel, growthexperiments-homepage-enable, growthexperiments-homepage-pt-link, mf_amc_optin, popups, popupsreferencepreviews, skin, mfMode19
20207VectorSkinVersion, betafeatures-auto-enroll, discussiontools-betaenable, echo-notifications-blacklist, email-blacklist, growthexperiments-help-panel-tog-help-panel, growthexperiments-homepage-enable, growthexperiments-homepage-pt-link, mfMode, mf_amc_optin, popups, popupsreferencepreviews, skin23
20208VectorSkinVersion, betafeatures-auto-enroll, discussiontools-betaenable, echo-notifications-blacklist, email-blacklist, growthexperiments-help-panel-tog-help-panel, growthexperiments-homepage-enable, growthexperiments-homepage-pt-link, mfMode, mf_amc_optin, popups, popupsreferencepreviews, skin46
20209VectorSkinVersion, betafeatures-auto-enroll, discussiontools-betaenable, echo-notifications-blacklist, email-blacklist, growthexperiments-help-panel-tog-help-panel, growthexperiments-homepage-enable, growthexperiments-homepage-pt-link, mfMode, mf_amc_optin, popups, popupsreferencepreviews, skin516196

So…still an issue

I've been poking at this as time permits but haven't yet managed to track down a cause. Interestingly, eyeballing some data from yesterday, it seems to happen particularly often for popupsreferencepreviews events.

I'm curious to see whether this problem persists after the migration of this instrument to MEP is finished. (At time of writing, it's only using MEP on testwiki.) If nothing else, it'll give us some better metadata to use for investigation.

OK, after running a couple of queries for the past couple of days, it looks like the worst offender is in fact mf_amc_optin, followed by popupsreferencepreviews, then discussiontools-betaenable, then a handful of others with a duplicate or two per day.

For example:

SELECT event.property AS property, COUNT(*) AS duplicated_events
FROM (
  SELECT event, COUNT(*) AS copies
  FROM event.prefupdate 
  WHERE year = 2021 AND month = 2 AND day = 15
  GROUP BY event
  HAVING COUNT(*) > 1) AS events
GROUP BY event.property
ORDER BY duplicated_events DESC;

returns:

propertyduplicated_events
mf_amc_optin477
popupsreferencepreviews214
discussiontools-betaenable59
skin2
popups2
VectorSkinVersion1

The only factor I can find in common among the duplicated events is that the vast majority of them are coming from mobile user agents. (No particular platform or browser stands out, however.)

Change 665236 had a related patch set uploaded (by Mholloway; owner: Michael Holloway):
[mediawiki/extensions/MobileFrontend@master] Fix: Save user options only once when Advanced Mode is toggled

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

Jdlrobson added a subscriber: Jdlrobson.

I believe a review here is required from our team.

Change 665236 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Fix: Save user options only once when Advanced Mode is toggled

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

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Big Sur
Browser: Chrome
Device: MBP
Emulated Device: iPhone 11 Pro Max

Test Artifact(s):

QA Steps

AC1: Verify that opt-in and out from Beta and AMC modes work properly on a mobile site.

AMC OnAMC Off
Screen Recording 2021-03-11 at 9.42.57 AM.mov.gif (898×416 px, 592 KB)
Screen Recording 2021-03-11 at 9.40.25 AM.mov.gif (898×416 px, 326 KB)

AC2: Also, please double-check that saving user preferences works with, and without Javascript.

JS EnabledJS Disabled
Screen Recording 2021-03-11 at 9.37.06 AM.mov.gif (898×416 px, 250 KB)
Screen Recording 2021-03-11 at 9.37.55 AM.mov.gif (898×416 px, 160 KB)

Change 670923 had a related patch set uploaded (by Mholloway; owner: Michael Holloway):
[mediawiki/extensions/WikimediaEvents@master] onUserSaveOptions: Warn and abort when originalOptions are empty

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

From my preliminary spot checking, the patch appears to have eliminated duplicates on the group 0 and 1 wikis to which it's been deployed so far. I look forward to seeing the results after it's promoted to group 2 this afternoon.

Also, I've just uploaded a follow-up patch to help unearth remaining cases of similar behavior (if any) and prevent regressions.

Change 670979 had a related patch set uploaded (by Mholloway; owner: Michael Holloway):
[mediawiki/extensions/MobileFrontend@master] Save user options only once when Advanced Mode is toggled, take 2

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

Edtadros added a subscriber: Edtadros.

Test Result - Prod

Status: ✅ PASS
Environment: enwiki
OS: macOS Big Sur
Browser: Chrome
Device: MBP
Emulated Device: iPhone 11 Pro Max

Test Artifact(s):

QA Steps

AC1: Verify that opt-in and out from Beta and AMC modes work properly on a mobile site.

AMC OnAMC Off
Screen Recording 2021-03-14 at 8.14.08 PM.mov.gif (898×416 px, 1 MB)
Screen Recording 2021-03-14 at 8.16.13 PM.mov.gif (898×416 px, 1 MB)

AC2: Also, please double-check that saving user preferences works with, and without Javascript.

JS EnabledJS Disabled
Screen Recording 2021-03-14 at 8.17.23 PM.mov.gif (898×416 px, 216 KB)
Screen Recording 2021-03-14 at 8.18.23 PM.mov.gif (898×416 px, 154 KB)
Edtadros updated the task description. (Show Details)
LGoto added a subscriber: ovasileva.

@nray Do you plan to review updated patch (updated only to add a null check), or can @jlinehan and I get it merged today to roll out this week?

Change 670923 merged by jenkins-bot:
[mediawiki/extensions/WikimediaEvents@master] onUserSaveOptions: Warn and abort when originalOptions are empty

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

@Mholloway Sorry for the delay on that, I will for sure review it today after I get done with meetings

No worries, @nray! Thanks for the update.

Change 670979 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Save user options only once when Advanced Mode is toggled, take 2

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

@Edtadros There was a patch on this ticket that was reverted, modified, and then merged again so please follow the same QA steps you did in https://phabricator.wikimedia.org/T218835#6912461 to make sure everything is still working

nray added a subscriber: nray.

@Edtadros There was a patch on this ticket that was reverted, modified, and then merged again so please follow the same QA steps you did in https://phabricator.wikimedia.org/T218835#6912461 to make sure everything is still working

you got it.

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Big Sur
Browser: Chrome
Device: MBP
Emulated Device: iPhone 11 Pro Max

Test Artifact(s):

QA Steps

AC1: Verify that opt-in and out from Beta and AMC modes work properly on a mobile site.

AMC OnAMC Off
Screen Recording 2021-03-24 at 5.39.47 AM.mov.gif (824×416 px, 747 KB)
Screen Recording 2021-03-24 at 5.40.55 AM.mov.gif (824×416 px, 709 KB)

AC2: Also, please double-check that saving user preferences works with, and without Javascript.

JS EnabledJS Disabled
Screen Recording 2021-03-24 at 5.42.47 AM.mov.gif (824×416 px, 377 KB)
Screen Recording 2021-03-24 at 5.43.28 AM.mov.gif (824×416 px, 140 KB)

The fixed patch finally rolled out on Tuesday 3/30 with 1.36.0-wmf.36. It looks like it's almost completely eliminated duplicate PrefUpdate events, down from several hundred duplicates per day prior to the change. Yesterday there were no duplicate events, and today so far there is only one duplicate popupsreferencepreviews event.

Test Result - Prod

Status: ✅ PASS
Environment: enwiki
OS: macOS Big Sur
Browser: Chrome
Device: MBP
Emulated Device: iPhone X

Test Artifact(s):

QA Steps

AC1: Verify that opt-in and out from Beta and AMC modes work properly on a mobile site.

AMC OnAMC Off
Screen Recording 2021-04-02 at 11.31.12 AM.mov.gif (816×378 px, 806 KB)
Screen Recording 2021-04-02 at 11.33.00 AM.mov.gif (816×378 px, 1 MB)

AC2: Also, please double-check that saving user preferences works with, and without Javascript.

JS EnabledJS Disabled
Screen Recording 2021-04-02 at 11.34.29 AM.mov.gif (816×378 px, 391 KB)
Screen Recording 2021-04-02 at 11.35.58 AM.mov.gif (816×378 px, 232 KB)

The fixed patch finally rolled out on Tuesday 3/30 with 1.36.0-wmf.36. It looks like it's almost completely eliminated duplicate PrefUpdate events, down from several hundred duplicates per day prior to the change. Yesterday there were no duplicate events, and today so far there is only one duplicate popupsreferencepreviews event.

That's great! I will go ahead and sign this one off