Page MenuHomePhabricator

Gracefully handle outdated echo_unread_wikis rows when a notification type has changed categories (alert->message or v.v.)
Closed, ResolvedPublic

Description

When a notification type is changed from being an alert to a message (e.g. because of T123018), we will get glitchy cross-wiki notifications behavior:

  1. User receives a thanks notification on frwiki. Thanks is an alert, so we store (frwiki, 1, 0) in the database
  2. Thanks changes from being an alert to being a message
  3. User views notifications on enwiki.
    • In the alerts section, a cross-wiki bundle appears with "1 alert from frwiki". Opening this bundle will show nothing, because there are no alerts on frwiki.
    • In the messages section, no cross-wiki bundle appears, so the user cannot access the thanks notification at all.
  4. A maintenance script rebuilds the table, or the user receives another frwiki notification; this changes the row to (frwiki, 0, 1) and things work correctly again.

The intermediate state in #3 is a problem, and would potentially persist for weeks. We could work around this by checking if a transition config flag is set, and if it is, looking at both alerts and messages on each foreign wiki (even if the table has a 0 in that column). This would be hard to do with our current client-side fetch setup, but easier with T130636: Cross-wiki notifications: Make cross-wiki API requests server-side.

Event Timeline

Catrope created this task.Apr 18 2016, 6:50 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 18 2016, 6:50 PM
  1. User views notifications on enwiki.
  • In the alerts section, a cross-wiki bundle appears with "1 alert from frwiki". Opening this bundle will show nothing, because there are no alerts on frwiki.

A foreign source that ends up being empty is removed. (handled in https://gerrit.wikimedia.org/r/#/c/288649/)

  • In the messages section, no cross-wiki bundle appears, so the user cannot access the thanks notification at all.

What do we want to see in this case?

The idea is that in transition mode, the client (which is now the server side of the local wiki) will check the current type of all notifications, and re-sort them.

So after seeing, "1 unread alert, 0 unread messages from frwiki", it will query to get the actual "alert". Then, it will see, "1 thanks from frwiki", then check the current type of thanks, then get "1 message from frwiki". This dynamic re-sorting is temporary until the new sorting scheme is final on all wikis.

Change 291676 had a related patch set uploaded (by Catrope):
[WIP] Gracefully handle outdated echo_unread_wikis rows

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

Catrope claimed this task.May 29 2016, 9:00 PM

Change 293314 had a related patch set uploaded (by Catrope):
Implement backfillUnreadWikis.php in terms of resetNotificationCount()

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

Catrope added a comment.EditedJun 8 2016, 2:19 PM

Change 293314 had a related patch set uploaded (by Catrope):
Implement backfillUnreadWikis.php in terms of resetNotificationCount()
https://gerrit.wikimedia.org/r/293314

We need this because if this script makes changes to echo_unread_wikis, it also needs to update cached count values that are based on this table.

Change 293314 merged by jenkins-bot:
Implement backfillUnreadWikis.php in terms of resetNotificationCount()

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

Change 295234 had a related patch set uploaded (by Catrope):
Enable Echo transition flags in beta labs for testing

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

Change 295234 merged by jenkins-bot:
Enable Echo transition flags in beta labs for testing

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

Change 291676 merged by jenkins-bot:
Gracefully handle outdated echo_unread_wikis rows

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

Change 295335 had a related patch set uploaded (by Sbisson):
Define global transition vars before using them

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

Change 295335 merged by jenkins-bot:
Define global transition vars before using them

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

Checked in betalabs - re-categorized notifications count/bundle opening runs smoothly and correctly.

jmatazzoni closed this task as Resolved.Jul 5 2016, 11:09 PM