Last Comment Bug 527687 - msgsClassified event may fire multiple times for a single message
: msgsClassified event may fire multiple times for a single message
Status: RESOLVED FIXED
: fixed-seamonkey2.0.1
Product: MailNews Core
Classification: Components
Component: Database (show other bugs)
: Trunk
: All All
: P2 normal (vote)
: Thunderbird 3.0rc1
Assigned To: Andrew Sutherland [:asuth]
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-11-10 08:12 PST by Andrew Sutherland [:asuth]
Modified: 2009-12-13 06:05 PST (History)
3 users (show)
davida: blocking‑thunderbird3+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
make msgsClassified only ever generate a single msgsClassified notification for a message v1 (25.16 KB, patch)
2009-11-10 14:07 PST, Andrew Sutherland [:asuth]
mozilla: review+
mozilla: superreview+
Details | Diff | Splinter Review

Description Andrew Sutherland [:asuth] 2009-11-10 08:12:57 PST
It sounds like the problem where msgsClassified tells us about messages we already know about is worse than hoped for.

If a user receives a new messages in a folder, a msgsClassified event is generated for _all_ the messages marked as new in that folder.  Because we limit the number of event-driven messages to be indexed to 20 and the folder indexing sweep logic is pretty good, in the pathological worst-case we will:
- redundantly index 20 messages that do not need to be indexed
- undertake a filtered enumeration of the messages in the folder (C++ enumeration of all headers)
- index the messages that actually are new and have not been indexed

This problem likely interacts with fast-pathing IMAP moves and the un-delete case.  Unfortunately, there may be no zero-cost solution since we may be unable to easily disambiguate amongst all the possible cases and so always have to perform a db lookup to check the message's location to see if we need to update it.  We might be able to mitigate by marking messages using processing flags during the msgAdded event assuming those get cleaned up if the message ends up getting moved by the spam detection.
Comment 1 Andrew Sutherland [:asuth] 2009-11-10 14:07:18 PST
Created attachment 411518 [details] [diff] [review]
make msgsClassified only ever generate a single msgsClassified notification for a message v1

I should have just done this originally instead of bothering with the workaround.

This patch introduces a new processing flag that gets set on message headers just after we generate the msgAdded nsIMsgFolderListener notification.  We only generate a msgsClassified notification for messages with the processing flag and we clear it when we generate it.  This allowed me to remove the workaround from messageInjection.js which should improve our mozmill troubles.

I also tried to improve logic related to the processing flags.  Namely, I cause us to remove the processing flags for a header when it is removed from the database.  Additionally, I cause us to clear all processing flags when the folder gets compacted.  I opted not to clear the processing flags in the reparse case since one could make the case that in that situation either 1) there are no processing flags because this is a first-open-this-session case or 2) there should theoretically be no message key changes for a 'rebuild index' triggered by the user.

I think clearing the processing flags is probably important for the TraitsDone and FiltersDone which are arguably very close to being memory leaks and bad for correctness in the face of compaction.  (Although there is some mitigation in the IMAP case where UIDs have a high probability of playing right into the message key set's run-length encoding mechanism.  Local folders will not have consecutive message keys and will suck.)
Comment 2 David :Bienvenu 2009-11-10 15:19:44 PST
Comment on attachment 411518 [details] [diff] [review]
make msgsClassified only ever generate a single msgsClassified notification for a message v1

r/sr=me
Comment 3 Andrew Sutherland [:asuth] 2009-11-10 23:03:48 PST
pushed to trunk:
http://hg.mozilla.org/comm-central/rev/12ceaa786d23

pushed to trunk:
http://hg.mozilla.org/releases/comm-1.9.1/rev/f34b497649e0

Note You need to log in before you can comment on or make changes to this bug.