Hi everyone,
I’m opening this brainstorming after starting to investigate for fixing Loading.... A brief recap: right now for notifications we use notification filters defined by users that allows to specify which pages are watched or not. Those filters are then used to process the events and send notification to the concerned users.
The bug is that right now filters can be created automatically with the autowatch features, but they’re never deleted when a document is deleted.
My first intuition is that it would be easy to fix: we provide a listener to listen on DocumentDeletedEvent and we remove the filter when the event is triggered. The problem is that if we do that, then we’ll lose the delete notifications for users watching specifically those pages: the events for notifications are processed in a low priority thread, so it’s expected that when the thread process the events, the filters has already been removed by the listener, and then the document won’t be considered watched by the user anymore, and so the notification won’t be sent.
Now if we don’t do that with a listener, the only remaining options I can think of are either using a TaskConsumer or a Scheduler.
With the TaskConsumer we’d create a task with the listener to clean up the filters, which would also be processed in a low priority thread. Now to my knowledge we cannot really tell this task to be performed after notifications are processed, so we don’t know which willl be faster between notification or this task.
For the Scheduler, the idea is to not tie at all the cleaning of the filters to any event, but only to a date: we’d perform regularly the clean up, like every week. On the pro side we shouldn’t have a problem of synchronization between the moment the filter is removed and the moment the notification is handled, most of the time. On the cons side: I’m not yet 100% sure about the scalability of this solution: we’d need to clean up all filters of all users, since we wouldn’t know if or what pages have been deleted since last call. It probably could be done with an HQL query, but that has to be tested. Also there is still a very slight chance to have a synchronization bug if a notification related to a deleted document is processed at the same time as the scheduler runs.
So to sum up, on “when cleaning up” we have 3 possibilities:
- use a listener but then accept that we’ll get a regression on deletion events: pretty sure everyone will be -1 on that one
- use a TaskConsumer and accept that result will be random
- use a Scheduler and accept possible scalability issue
- do nothing and accept to pile up filters (current situation)
Now on the “what filters”: right now the notification filters might concern either the page alone, or the page and its children. By default, when the autowatch feature is used, it creates a filter for the page alone. But a user chosing to watch manually something might use the button to watch a space (page and children).
So if we do something for cleaning up automatically filters, I was thinking to only cleaning up the filters concerning the “page alone”, and not the filters about the page and its children. This means that, even if we provide a fix, it’s still possible that filters pile up if people watches spaces, as those would never be removed automatically. Now it will be clearly slower than with the autowatch feature.
IMO that’s acceptable, but would be great if I can have other opinions too. WDYT?