-
-
Notifications
You must be signed in to change notification settings - Fork 676
Fix broken notification incremental sync #2701
Fix broken notification incremental sync #2701
Conversation
Tests are broken, but I see the same errors on other PRs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The upgrade tests are currently broken, but Complement seems to be unhappy with the change.
The problem is that the SyncAPI sends the event to the UserAPI, which in turn sends the unread count. This can race and we receive the unread count way after we left the room. With this change we would add the room to the response, even if we might already have left the room.
#2688 is using a different approach, by listening on a different stream and producing the unread counts earlier. Unfortunately, this can still race, but is more reliable (in my tests).
Thank you for the quick response. If you don't mind, can you answer two questions for me?
Thank you for your time! |
I don't know the answer to the first but I'll try to answer the second question:
The client may or may not ignore the notification, but it's not a good idea to assume this about a client and rely on that behavior because there are no guarantees and it could confuse users. In addition, it causes unnecessary network traffic which can mean additional mobile data usage, more battery usage and slower notifications. It's not the end of the world but it's not a good design. |
Usually you want to deliver notifications either at least once or exactly once. As a user I'm pretty used to seeing a text message get delivered again if I'm in a spotty network (though I haven't seen it in a while). Currently dendrite is delivering notifications sometimes. Just something to think about. |
I believe the issue with this change is not that the notification gets re-delivered but rather that it gets delivered potentially after a room has been left by the user, right? In which case delivering the notification is bad for the aforementioned reasons and because the user is unable to view the message anyway (as they have left the room) so it is confusing.
I agree that this should be fixed but I think the point being made is that this isn't a suitable solution. |
You are right, that was a bad example, with this change the notifications won't get redelivered. Let me rephrase. I'm a user. I just left a space (which I hardly ever do) and I receive a notification saying I have a new message in that space. Seeing that I just left the space, I'm probably a little confused, but I remember that matrix is a federated distributed system run by a non profit and it's not perfect, and I go about my day. OR, I'm a user, and I never get unread notifications. I miss new messages in conversations that I'm trying to participate in all the time. I'm probably going to stop using this product. I'm sorry if I'm coming across as harsh, I'm not meaning to be. I'm saying this with smiles that you would be able to see if we were in person. I just want to be as direct as possible because it feels like I'm missing something. |
d26af75
to
451b09c
Compare
Okay! I went through some more tests on my end and you were right, this wasn't the right fix, the join message is the wrong place for this data. I updated my code. It leaves everything else in place and adds a new object to the response that matches the sync pattern you have going on here. It requires client changes but they're pretty simple in theory (in practice I added my own memory store that allows me to get access to the raw sync data and pulled the numbers from there.) I'd love feedback, but also fine if you just close this request. |
451b09c
to
4f3f982
Compare
I was not seeing unread notifications in sync, even if they were written to the db Notifications are in their own stream, but the code was trying to tack them onto the join room stream. If the offsets “happened” to line up, you might get a count here or there, but they would be totally wrong (jump from 1 to 0 to 2, etc) To fix, put them in their own top level object, handle them on the client. Signed-off-by: Austin Ellis <austin@hntlabs.com>
4f3f982
to
4e30e03
Compare
In case anyone is still listening to this thread, if I'm reading the code correctly, it looks like we cleanup the notification table after a day
But we don't clean up the notifications in the syncAPI table. When we send a read receipt we first do a |
I couldn’t clear notifications for messages greater than 1 day old because they no longer existed :)
} | ||
//} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this bug probably happens with fully read too, i haven't tested that yet.
Closing this, since #2688 is now merged and solves the same problem. |
#2743) …ce {}, a slice of interface` in new notifications select The sqlite3 version was just not working, original pr here: #2688 signed off by: austin ellis <austin@hntlabs.com> This doesn't fix the notification counts, they still only work about 1 out of every 5 times in my tests. I will stick with my other fix locally for reliable notification delivery: #2701
I was not seeing unread notifications in sync, even if they were written to the db
Notifications are in their own stream, but the code was trying to tack them onto the join room stream. If the offsets “happened” to line up, you might get a count here or there, but they would be totally wrong (jump from 1 to 0 to 2, etc)
To fix, put them in their own top level object, handle them on the client.
Signed-off-by:
Austin Ellis <austin@hntlabs.com>
Pull Request Checklist