We should have a script that will backfill the echo_unseen_wikis table instead of waiting on users to trigger cache invalidation through receiving or reading notifications.
Description
Details
Event Timeline
I see that NotifUser::resetNotificationCount does that in different context.
Any reasons why looping on the users and calling it would be a bad idea?
It has unintended side-effects that we probably don't want like setting it in memcached and invalidating the user cache. Also if possible we should aim to do batch inserts.
Change 259265 had a related patch set uploaded (by Matthias Mullie):
Backfill echo_unread_wikis table
wikishared.echo_unread_wikis table is properly updated for the following cases:
- when a user initiates an action that sends alerts/notifications to another user
- when a recipient of notifications from the previous step marks some(all) messages/alerts
- in flyout or
- go to Notifictions page.
Technically, that is testing the normal flow, not the backfill.
We should be able to test the backfill as part of the MediaWiki-Vagrant stuff. I'm working on a patch for this now (to auto-run it on provision).
Change 264257 had a related patch set uploaded (by Mattflaschen):
Backfill echo_unread_wikis table after it is created
@Etonkovidova If you want to test this on MediaWiki-Vagrant:
- DROP the echo_unread_wikis table in the wikishared DB (it will probably only exist if you tested the prior patch in this chain).
- Create whatever notifications you want to test.
- Checkout https://gerrit.wikimedia.org/r/264257
- vagrant provision
It will create and backfill the table. You can also run the script manually at any time if you want.
Sorry, when I posted the above, my brain was stuck on "test the users" mode, since part of the point was to have the PHP app use separated users.
However, the root user still exists (even if the app doesn't use it), so you can do:
mysql wikishared
I can still add that to MOTD if you think it's useful (there's a manifest, so it can easily be done only if Echo is installed).
Nice catch on the Puppet ordering problem. Fixed in latest patch.
So, you can:
- DROP again.
- Create notifications.
- Checkout latest https://gerrit.wikimedia.org/r/#/c/264257
- vagrant provision
Rechecked locally actual backfill action with the steps given by @Mattflaschen
- wikishatred.echo_unread_wikis is created upon Notifcations are triggered
- e.g. euw_user=6 has Alerts form frwiki and Messages from wiki, It is be recorded in wikishatred.echo_unread_wikis as the following:
root@localhost:[wikishared]> select * from echo_unread_wikis;
euw_id | euw_user | euw_wiki | euw_alerts | euw_alerts_ts | euw_messages | euw_messages_ts |
2 | 1 | wiki | 2 | 20150716223405 | 0 | 00000000000000 |
3 | 6 | frwiki | 1 | 20160116002634 | 0 | 00000000000000 |
4 | 6 | wiki | 0 | 00000000000000 | 1 | 20160116003155 |
After euw_user=6 viewed Alerts in frwiki, the table is updated.
euw_id | euw_user | euw_wiki | euw_alerts | euw_alerts_ts | euw_messages | euw_messages_ts |
2 | 1 | wiki | 2 | 20150716223405 | 0 | 00000000000000 |
4 | 6 | wiki | 0 | 00000000000000 | 1 | 20160116003155 |
Change 264257 merged by jenkins-bot:
Backfill echo_unread_wikis table after it is created