Page MenuHomePhabricator

Notifications: "Mark all Read" not clearing unread notifications list
Closed, ResolvedPublic

Description

I have a feeling I somehow got my install into this state via magic... But I've had this nice little "82" on my home screen for about a week.

Screen_Shot_2014-08-27_at_3.34.59_PM.png (59×281 px, 9 KB)

My very weak reproduction steps:

  1. Observe large number of things I'm not interested in.
  2. Click "Mark all as Read"
  3. Confirm in modal prompt.
  4. Notifications are still there.

Event Timeline

mholden raised the priority of this task from to Needs Triage.
mholden updated the task description. (Show Details)
mholden added a subscriber: mholden.

Blindly associating this with the "Notifications" project because that sounds like it would make sense.

Thanks for the report. I am 99% sure this is some fallout from fixing T5975.

Hmmm, I can't seem to repro this. Would the "magic" involve making things with weird timestamps?

The product behaves by design with a little white lie; "Mark All Read" actually only marks all read everything prior to the set of notifications you are looking at. This only really comes into play if / when you start paging through the full set of notifications and otherwise behaves as labelled.

If it would help, I can paste the results of any SQL I can run that might help you see what's going on..?

To cut to the chase a bit, can you talk more about the "magic" that you might have done to your instance? I don't think we should bother debugging stuff if you're confident its something you did to your instance.

In terms of debugging, can you figure out your chronoKey value for clicking Mark All Read? Here's mine I got from copying the link to the clipboard

https://secure.phabricator.com/notification/clear/?chronoKey=6052706450777759162

Can you figure out your userPHID? It is accessible here

https://secure.phabricator.com/api/user.whoami

The table in question is phabricator_feed.feed_storynotification. The code basically says

'UPDATE phabricator_feed.feed_storynotification SET hasViewed = 1 '.
'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %d'

So it would be interesting to see results for queries like

'SELECT count(1) FROM phabricator_feed.feed_storynotification WHERE userPHID = %s and chronologicalKey > %d'  // should be 0
'SELECT * FROM phabricator_feed.feed_storynotification WHERE userPHID = %s AND hasViewed = 0'  // these are the actual rows that don't seem to be getting marked read

Sorry I took a day to get back.

From the look of things, sounds like my chrono key is the problem...?

As far as the "magic state"; I just talking about that state in any app that as a developer, I can never create, but all my QA and end users can; but nobody knows how... :)

As I recall though (it's been a really really busy week) I had *just* updated my install (main repo, arc, libphutil, as well as running bin/storage upgrade). HEAD in my ./phabricator working copy shows 53a678c56823e863eead3959f82cd8477f59740f

Chrono Key: 6052774592759489916
phid: PHID-USER-3ghi26qltwrkfl3iluol


mysql> select count(1) from phabricator_feed.feed_storynotification WHERE userPHID = 'PHID-USER-3ghi26qltwrkfl3iluol' and chronologicalKey > '6052774592759489916';
+----------+
| count(1) |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

mysql> SELECT * FROM phabricator_feed.feed_storynotification WHERE userPHID = 'PHID-USER-3ghi26qltwrkfl3iluol' AND hasViewed = 0; 
+--------------------------------+--------------------------------+---------------------+-----------+
| userPHID                       | primaryObjectPHID              | chronologicalKey    | hasViewed |
+--------------------------------+--------------------------------+---------------------+-----------+
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-277ocfcaauirxfm56dkj | 6049418412890526080 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-2gj4xc72hykrz7jvtc4j | 6046334816148345100 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-2hjvp2wq6hjgwkt7whav | 6052767998444882489 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-3sbe7fhc3wsu3vr76wta | 6047125111847093665 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-3v5jtta5g54nbjoibxod | 6046830750401445341 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-3z26g3dmmrg3zpzy4ntx | 6046338283951122001 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-4gijinzyqzevbukkx4u2 | 6045270483007974510 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-55gkktrewyzrbms7glkp | 6045327705364661063 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-5g6rwkhxrpn3cuq75tx2 | 6046749589131530482 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-5g6rwkhxrpn3cuq75tx2 | 6046798721967576610 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-7uapzqssf7svr7gjstde | 6048936172781293070 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-7uapzqssf7svr7gjstde | 6048939082611884293 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-a6ly6wdklkj2mjgrftht | 6045265711183621310 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-ag35wxi2e3z7grby54rb | 6046340354452317393 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-ag35wxi2e3z7grby54rb | 6046346979702701128 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-amb6swujq6ju4by6v33z | 6047082393540283926 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-bsoysaunbc7onzpe4acg | 6046419527108064590 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-bsoysaunbc7onzpe4acg | 6046420266819873104 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-e2kmnrjacpm5ghvsgtel | 6047532640946836649 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-e2kmnrjacpm5ghvsgtel | 6047536743223030211 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-e2kmnrjacpm5ghvsgtel | 6047562735372938718 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-e2kmnrjacpm5ghvsgtel | 6047564841854128387 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-emva5oxxjgejzwsu2obz | 6049684338225986991 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-eswrbojp6tfqsthsktlj | 6046377768415727002 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-et7efoiwhochxm6e6cz2 | 6049005395529355199 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-ex2pieo7o6srd7djbfi2 | 6046411855494532099 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-ex2pieo7o6srd7djbfi2 | 6046434363663541019 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-ftd2qraxivn6dmca7nvo | 6047102945811577340 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-fvlu5h2w4m4rjmuzyvws | 6046471856035615783 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-fvlu5h2w4m4rjmuzyvws | 6046472817601446308 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-fvlu5h2w4m4rjmuzyvws | 6046475297280452379 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-fvlu5h2w4m4rjmuzyvws | 6046496280516797497 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-ixpgtry5lyc65shdqfsd | 6044941752355121524 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-kak356pdhg6koxwsoxse | 6044920515270796339 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-kak356pdhg6koxwsoxse | 6044941534844063009 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-lvib2s55v6h3g3twnhyd | 6044558235469459908 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-mw4hfaxl7uojlu2pw5x3 | 6046428467684402009 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-nbmmg3emrxnq6twpoy2c | 6048650587153411137 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-nbmmg3emrxnq6twpoy2c | 6049036248972013880 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-nemaftfauxc3r3ot437p | 6048651529614276856 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-nh7y6fbebzimp44frd6r | 6046411695539753535 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-nh7y6fbebzimp44frd6r | 6046419622275168081 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-nh7y6fbebzimp44frd6r | 6046447464728205801 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-ottvvswyksyw4yin5ija | 6046464025741219077 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-pk7w3a2twttgvdbhqqeo | 6047115195222066741 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-pk7w3a2twttgvdbhqqeo | 6047115239648826985 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-pk7w3a2twttgvdbhqqeo | 6047115268416878083 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-pk7w3a2twttgvdbhqqeo | 6047191873070946448 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-r4zxr2sznubnmp4o6mqy | 6046831951261991081 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-r4zxr2sznubnmp4o6mqy | 6046834058395599057 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-r4zxr2sznubnmp4o6mqy | 6046835024970908883 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-rvoctxzdbrlovhn2e3vo | 6046827311885648766 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-thlfqlb5bcm2re6bcry3 | 6046745741110987672 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-thlfqlb5bcm2re6bcry3 | 6046746976066985817 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-thlfqlb5bcm2re6bcry3 | 6046748250957985515 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-tmisnj2n6b37zfk2znib | 6049030010738089675 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-tp3np2cju7iiqhodnax2 | 6044545930078480793 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-tp3np2cju7iiqhodnax2 | 6044550269124287526 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-tvun33xhurvryrh26r4a | 6048971913547596819 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-ub5kb26ot46odas7254q | 6045232467237205963 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-uskp7stlvzrysi7sba4m | 6046712682686353884 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-uskp7stlvzrysi7sba4m | 6046712825820624973 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-uzue3zzguuclljo3mh6c | 6048649343716245675 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-uzue3zzguuclljo3mh6c | 6048971383405383242 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-w3tm4kkcziuflsvlbzzp | 6044557076754977784 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-web6gkosrfnyswunndaa | 6044947515698068523 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-wgyta5izbnnv47aci2he | 6044961446378099587 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-wqik4447wbgbgay3iuyf | 6044524404520485273 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-xjhzvanhw7lhx65mapmn | 6045317675728301710 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-xlmbuufaejudoewtnt4j | 6046793415774726486 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-xlmbuufaejudoewtnt4j | 6046799915021913711 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-xlmbuufaejudoewtnt4j | 6046801500563811940 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-xlmbuufaejudoewtnt4j | 6046801544624989218 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-xlmbuufaejudoewtnt4j | 6046801575202669006 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-yh2ataliythiqttihvru | 6049011966928527955 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-z3yu5l4lscpghwcgzfkf | 6045343763732073365 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-zood64v4s4i5hdkm5jfu | 6048940357759197835 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-DREV-zp6zmigf4ir6yjzar6yk | 6045334674295661721 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-USER-3ghi26qltwrkfl3iluol | 6049447727472803916 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-USER-3ghi26qltwrkfl3iluol | 6049447733735798035 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-USER-3ghi26qltwrkfl3iluol | 6049447753496565575 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-USER-3ghi26qltwrkfl3iluol | 6049447757940068148 |         0 |
| PHID-USER-3ghi26qltwrkfl3iluol | PHID-USER-3ghi26qltwrkfl3iluol | 6049448152279123655 |         0 |
+--------------------------------+--------------------------------+---------------------+-----------+
83 rows in set (0.00 sec)
btrahan added subscribers: epriestley, btrahan.

@epriestley - I am wildly stumped on this one. Code should work; does not.

chad triaged this task as Normal priority.Sep 2 2014, 5:28 PM

Just to clarify this issue is on a single instance only. I think @mholden has provided evidence that somehow the sql query which should work isn't. I am not sure what ghosts could be living in this specific instance, and of course perhaps this is just the first instance of this problem we've seen reported...

@mholden, can you show us the output of this command on your system?

$ php -r 'echo PHP_INT_MAX."\n";'

Aha! Can you try this patch and see if it works?

diff --git a/src/applications/notification/controller/PhabricatorNotificationClearController.php b/src/applications/notification/controller/PhabricatorNotificationClearController.php
index b0caa8b..d07a4ae 100644
--- a/src/applications/notification/controller/PhabricatorNotificationClearController.php
+++ b/src/applications/notification/controller/PhabricatorNotificationClearController.php
@@ -14,7 +14,7 @@ final class PhabricatorNotificationClearController
       queryfx(
         $table->establishConnection('w'),
         'UPDATE %T SET hasViewed = 1 '.
-        'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %d',
+        'WHERE userPHID = %s AND hasViewed = 0 and chronologicalKey <= %s',
         $table->getTableName(),
         $user->getPHID(),
         $chrono_key);

Wow, i didn't realize PHP could have super different values for PHP_INT_MAX beyond like 32 bit vs 64 bit OS and stuff like that.

Sure thing; I'll need to wait until tonight since we've got people using our install throughout the day, and I still haven't set up any sort of 'test' environment.

2147483647 is the value on 32-bit systems, but %d may not work properly with 64-bit integers on a 32-bit system. I'm guessing the actual query we're running is chronologicalKey < 12 (for some incorrect, 32-bit-coerced value of 12) instead of chronlogicalKey < 6052774592759489916.

Sorry I never got around to testing that temporary fix.

Just grabbed the latest from master and this issue is gone

Thanks!