MailCore / mailcore2

MailCore 2 provide a simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP. The API has been redesigned from ground up.
Other
2.62k stars 627 forks source link

uids fetched from gmail folder can be wrong occasionally #1256

Closed frankobe closed 9 years ago

frankobe commented 9 years ago

i discover an issue when fetch uids from certain gmail folder using:

MCOIndexSet *uidSet = [MCOIndexSet indexSetWithRange:MCORangeMake(localFirstUID, UINT64_MAX)]

MCOIMAPFetchMessagesOperation *fetchOperation =
    [self.imapSession fetchMessagesOperationWithFolder:folder
                                                requestKind:(MCOIMAPMessagesRequestKindFlags)
                                                       uids:uidSet];

[fetchOperation start: completionBlock];

Occasionally returned message uidset can miss a few uids compared with my local uid dataset. But for the next time fetching, those missed message can be found. I verify messages with missed uids belong to the folder based on gmail web.

The chance it happened can be around 1/50. I doubt it can be an error with gmail server return.

Just raise this to see who else encounter the similar issue. If it is true, double check needed when synchronizing between local and server

dinhvh commented 9 years ago

If you can reproduce, can you show connectionLogger logs? Thanks.

frankobe commented 9 years ago

In ConnectionLog: uids with 32041 and 32042 are logged,

* 16703 FETCH (X-GM-THRID 1515560500378804295 X-GM-MSGID 1515560500378804295 X-GM-LABELS () UID 32041 MODSEQ (2848117) INTERNALDATE "20-Oct-2015 14:25:24 +0000" FLAGS () ENVELOPE ("Tue, 20 Oct 2015 14:25:24 -0000" "This sale is sooo worth it." (("Anthropologie" NIL "Anthropologie" "email2.anthropologie.com")) (("Anthropologie" NIL "Anthropologie" "email2.anthropologie.com")) (("Anthropologie" NIL "support-b8hmpctb4xyhmuaupxg8vqc9bfgp0h" "email2.anthropologie.com")) ((NIL NIL "brownkun" "gmail.com")) NIL NIL NIL "<b8hmpctb4xyhmuaupxg8vqc9bfgp0h.14714997268.4784@mta614.email2.anthropologie.com>") BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "iso-8859-1") NIL NIL "8BIT" 771 24 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "iso-8859-1") NIL NIL "QUOTED-PRINTABLE" 15832 334 NIL NIL NIL) "ALTERNATIVE" ("BOUNDARY" "=b8hmpctb4xyhmuaupxg8vqc9bfgp0h") NIL NIL) BODY[HEADER.FIELDS (References Message-Id)] {97}

Message-ID: <b8hmpctb4xyhmuaupxg8vqc9bfgp0h.14714997268.4784@mta614.email2.anthropologie.com>

)

* 16704 FETCH (X-GM-THRID 1515560667191600560 X-GM-MSGID 1515560667191600560 X-GM-LABELS () UID 32042 MODSEQ (2848062) INTERNALDATE "20-Oct-2015 14:28:03 +0000" FLAGS () ENVELOPE ("Tue, 20 Oct 2015 14:28:02 +0000" "Ryan Hoover just posted \"Squad\" on Product Hunt" (("Product Hunt" NIL "hello" "producthunt.com")) (("Product Hunt" NIL "hello" "producthunt.com")) (("Product Hunt" NIL "hello" "producthunt.com")) ((NIL NIL "brownkun" "gmail.com")) NIL NIL NIL "<56264f6f5ba94_33fb70ad07108960771@005ea4ac-bf26-4fbe-9244-1f5a277e07cd.mail>") BODYSTRUCTURE (("TEXT" "PLAIN" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 4786 80 NIL NIL NIL)("TEXT" "HTML" ("CHARSET" "utf-8") NIL NIL "QUOTED-PRINTABLE" 10075 288 NIL NIL NIL) "ALTERNATIVE" ("BOUNDARY" "_av-N0mugxxKZPGKX37f5SYBAg") NIL NIL) BODY[HEADER.FIELDS (References Message-Id)] {93}

Message-Id: <56264f6f5ba94_33fb70ad07108960771@005ea4ac-bf26-4fbe-9244-1f5a277e07cd.mail>

)

However, uid 32041 and 32042 are not included in messages returns by fetchOperation.

MCOIMAPFetchMessagesOperation *fetchOperation =
    [self.imapSession fetchMessagesOperationWithFolder:folder
                                                requestKind:(MCOIMAPMessagesRequestKindFlags)
                                                       uids:uidSet];

uidSet = (32036, 32035) is return from

 MCOIndexSet *uidSet = [MCOIndexSet indexSetWithRange:MCORangeMake(32036, UINT64_MAX)]
dinhvh commented 9 years ago

MCORangeMake(32036, UINT64_MAX) means 32036 to +infinity. Therefore, 32041 and 32042 will be included.

frankobe commented 9 years ago

Yes. I see them in uid log but not in message returned. Just wonder why

dinhvh commented 9 years ago

Could you show me the full connectionLogger? Thanks!

frankobe commented 9 years ago

Full logger is too long, pls find it by: https://www.dropbox.com/s/nhmelrib6gn6120/connectionLogger.txt?dl=0

request uidset = (32116, UINT64_MAX). And uid in (32116, 32136) are missed. Thx

frankobe commented 9 years ago

after digging into the log, i think there are potentially uidset inconsistency in my code. So I will close the issue and thx for the help!