matrix-org / synapse

Synapse: Matrix homeserver written in Python/Twisted.
https://matrix-org.github.io/synapse
Apache License 2.0
11.82k stars 2.13k forks source link

Getting Wrong notif_count in event_push_summary table #16357

Closed gowtham18k closed 1 year ago

gowtham18k commented 1 year ago

Description

While using the matrix synapse server if I join a user or if I do any operation in a particular room, the notif_count in the event_push_summary table got increased randomly. Because of that the unread count for a particular room and for a user will be wrong.

image

Steps to reproduce

Homeserver

homeserver

Synapse Version

1.90.0

Installation Method

Docker (matrixdotorg/synapse)

Database

No

Workers

Single process

Platform

Kubernetes

Configuration

No response

Relevant log output

NA

Anything else that would be useful to know?

No response

DMRobertson commented 1 year ago

if I do any operation in a particular room, the notif_count in the event_push_summary table got increased randomly.

Is this one specific room or lots of individual rooms?

got increased randomly

What do you mean by "random" here? Do the counts increase in a predictable way each time?

The notif count represents the number of events---including e.g. users joining---in a room that the user wants to be aware of. It is separate from the highlight count, which is the number of urgent events the user wants to be aware of. Matrix is quite flexible (via push rules) in what it considers notifiable, so it's not obvious to me that counts going up are a bug.

Because of that the unread count for a particular room and for a user will be wrong.

Can you be more specific here? What unread count did you expect to see, and what did you actually see on the client? (I.e. how does this manifest to end users?)

gowtham18k commented 1 year ago

It is happening for lots of rooms. notif_count represents no.of events but Let me show what I got

  1. It shows the notif_count that I have 1
  2. I'm sending one message to the room using restApi 3
  3. Here, the count after sending one message to the room 2

In this case, sending 1 message counts as 1 event right? But the notif_count increased to 16 instead of 1

clokep commented 1 year ago

In this case, sending 1 message counts as 1 event right? But the notif_count increased to 16 instead of 1

I'm assuming the event was sent via a different user. (You don't get notifications from your own events.)

The stream ordering between those two screenshots is very large (~20k) which implies to me that a lot of events occurred between those two screenshots. Are you sure there are no other events that were also sent into that room?

gowtham18k commented 1 year ago

I'm sure that we are simply sending only one message from another user who is present in the same room. There are no more events triggered. The screenshot has been captured within a minute before and after sending one message which is in the second screenshot

clokep commented 1 year ago

The event_push_summary table doesn't usually show "live" data, it summarizes data every 30 seconds. I'm Are you also taking the data in event_push_actions into account? There's likely a single entry in there for the event ID you sent.

Note that the items aren't deleted immediately from event_push_actions after rotation, they're deleted after a few days.

gowtham18k commented 1 year ago

Yeah, It's right in event_push_actions we have a single entry. But the notif_count in event_push_summary is showing the wrong count. Even though we are showing the wrong notification count to the users.

" _The event_push_summary table doesn't usually show "live" data, it summarizes data every 30 seconds. I'm Are you also taking the data in event_pushactions into account? There's likely a single entry in there for the event ID you sent. "

The event_push_summary table is used to summarize the events for a single room right? But In this case how the notif_count will come to this number as mentioned earlier?

clokep commented 1 year ago

The event_push_summary table is used to summarize the events for a single room right? But In this case how the notif_count will come to this number as mentioned earlier?

Yes, but only up to a point (stored in event_push_summary_stream_ordering). If the corresponding entry in event_push_actions is after that stream ordering then it is not expected to be in event_push_summary.

clokep commented 1 year ago

It sounds like this is working as expected then?