GNOME Bugzilla – Bug 764581
Duplicate messages cause incorrect unread counts
Last modified: 2021-07-05 13:26:58 UTC
Reported here: https://mail.gnome.org/archives/geary-list/2016-April/msg00000.html Bug description: Three persons replied to my email address and put the email alias in Cc. I read all the messages an no message is marked as unread, but the unread count is still 3. It's still 3 after 3 days. By the way, it seems that I received really twice only one of these 3 messages. This is what I see in Geary and if I browse the MessageTable in the .db file. So geary is failing to sync with the server, as if after marking a single message (by message_id?) as read it didn't check if a duplicate of it exists.
I'm adding some notes for me and others who want to check this in the future. I launch sqlitebrowser, open the .db file, click on "Browse Data" tab and select the Message table, then click on Subject to sort by subject. I'm now having 15 unread count, which I've actually read. By looking at the database I see only one occurrence of the the same message, while the server has two copies of each. So Geary is marking one email as read but the duplicate remains unread on the server (and not "visible" in Geary). IIRC this would not happen on Gmail accounts, where duplicates are deleted. My email account is using a dovecot server.
I've just realized that this problem is caused by this particular account which does not have UIDPLUS enabled. I've created an alias/forward email to my primary account, which has UIDPLUS, and the unread count remain correct when I get the same email twice. So it's somehow related to bug #775263
Webfaction has now moved my account to a server where UIDPLUS is enabled. This morning I had the chance to test the unread count problem and it seemed to work fine finally. But now I'm getting 3 unread emails from yesterday evening: so Geary unread count is 3 but show no unread message; while webmail shows 3 unread count and 3 unread messages (the duplicates). I don't know what might be happened between early morning and now.
I'm having similar issues where unread count is left positive while all messages are actually read. I would need to check logs to see if that's related to your issue though.
This bug is quite annoying. Today I made a new debugging attempt. Let me recap the issue, as the previous comments (from me) are confusing. 1. STEPS TO REPRODUCE THE BUG You need an alias/forwarding email. During a conversation, when someone "reply to all" - that is to me and the alias - he will send two messages: one to my address and one to the alias (which is going to be forwarded to me). So I should receive 2 messages instead of 1. The same may apply to a mailing list where people reply to all and there's no reply-to-list enforced, but I could not test it on the problematic account. 2. SEEMS A SERVER SETTING PROBLEM I have 2 accounts. Both use Dovecot. Both have UIDPLUS enabled. Still they behave differently: - one downloads the two duplicates and the unread count is correct - one downloads only one message, so the unread count is incorrect. (No need to look at the database, just look at the conversation and count the messages.) The question is why it happens only on one account. I may ask the hosting provider if they have dovecot logs specific of my email account.
(In reply to Federico Bruni from comment #5) > The question is why it happens only on one account. > I may ask the hosting provider if they have dovecot logs specific of my > email account. Does the problematic account have a web mail interface? If so, can you see if the mail exists there twice or not? Also, if possible, open up the database for the account using sqlite3 or some other DB frontend and see if you can see two entries for the message in MessageSearchTable. It may be that the server for the problematic account has some kind of duplicate suppression enabled that is interacting weirdly with Geary.
In the webmail the message exists twice, one as read and one as not read. In MessageSearchTable the (received) message appears only once. (curiously my message, sent to two email addresses, appears 4 times)
Something not expected today: in the same thread where I have 3 unread (that is three duplicates not read only on the server/webmail), I received a reply from a person (let's call him Step) who wrote to me and the alias, as the others before. But this time I received two messages in Geary and only one on the webmail. The unread count did not grow up, it remains at 3. I don't think that I experienced something similar before.
This is another aspect of Geary's duplicate message handling that is a bit out of step with the IMAP model. When Geary detects duplicate messages (both within the same folder and in multiple folders) they are represented as a single message in the database, one that exists in multiple locations. However under IMAP, the message still exists multiple times and each copy has its own set of flags, including unread status. Geary should be updating all copies when the user changes a flag like unread, but it looks like it might not be doing the right thing for messages duplicated in the same folder. Another problem is if a duplicate message is updated by an different mail client (mobile, webmail, etc) and hence one copy all of a sudden has a different set of flags to the rest. To fix this, we need to do one of: 1. Ensure Geary also updates flags for duplicates in the same folder when they are changed, and when noticing changes to duplicates by another app also go and apply those changes to all other copies, to keep them all in sync 2. Start maintaining duplicate flags for each duplicate message, only update flags for the specific copy that is being referred to, and let it be resolved at the UI level, much like we do for conversations at the moment — e.g. display a message as being unread if any copy is unread. Personally, I think (1) is the way to go, since it will mean avoiding a lot of special casing of unread counts, which per Bug 750695 is already kind of sketchy, and (2) doesn't provide a way to mark a message as unread for duplicates in the same folder.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/geary/-/issues/ Thank you for your understanding and your help.