Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

0.6.x breaks caching clients that connected to 0.5.x in the past #512

Closed
foxcpp opened this issue Jun 27, 2022 · 4 comments
Closed

0.6.x breaks caching clients that connected to 0.5.x in the past #512

foxcpp opened this issue Jun 27, 2022 · 4 comments
Assignees
Labels
bug Something isn't working. go-imap-sql Issue that is caused by a problem in go-imap-sql.

Comments

@foxcpp
Copy link
Owner

foxcpp commented Jun 27, 2022

For some reason, clients do not show all messages if the database was created in 0.5.
Freshly created databases in 0.6 do not have the same issue.

Different clients show different messages, maddy imap-msgs correctly shows all messages.
If a new message is added, some (?) clients refresh and show all messages again.

@foxcpp
Copy link
Owner Author

foxcpp commented Jun 27, 2022

Excerpt from protocol trace with Thunderbird client:

42 select "INBOX"
...
* 17 EXISTS
* 17 RECENT
...
43 UID fetch 1:* (FLAGS)
* 1 FETCH (FLAGS (\Recent \Recent) UID 29)
* 2 FETCH (FLAGS (\Recent \Recent) UID 30)
* 3 FETCH (FLAGS (\Recent \Recent) UID 31)
* 4 FETCH (FLAGS (\Recent \Seen \Recent) UID 32)
* 4 FETCH (FLAGS (\Recent \Seen \Recent) UID 37)
* 4 FETCH (FLAGS (\Recent \Seen \Recent) UID 38)
* 4 FETCH (FLAGS (\Recent \Seen \Recent) UID 39)
* 4 FETCH (FLAGS (\Recent \Seen \Recent) UID 40)
* 4 FETCH (FLAGS (\Recent \Seen \Recent) UID 41)
43 OK UID FETCH completed

Horribly broken in multiple obvious ways (duplicate sequence numbers, UID not sorted)

@cbrake
Copy link

cbrake commented Jun 27, 2022

looks like you're on it! That explains why I'm seeing issues you did not see in testing.

@foxcpp foxcpp self-assigned this Jun 27, 2022
@foxcpp foxcpp added bug Something isn't working. go-imap-sql Issue that is caused by a problem in go-imap-sql. labels Jun 27, 2022
foxcpp added a commit to foxcpp/go-imap-sql that referenced this issue Jun 27, 2022
Lack of UIDs sorting trips go-imap-mess algorithms
that expect sorted uidsMap (e.g. for binary search).

See foxcpp/maddy#512
foxcpp added a commit that referenced this issue Jun 27, 2022
@foxcpp
Copy link
Owner Author

foxcpp commented Jun 27, 2022

I pushed the commit to master that should fix the issue.

The issue was caused by go-imap-sql passing unsorted UIDs list to go-imap-mess which uses binary search and therefore misbehaves when given an unsorted input. The bug did not manifest itself in 0.6 testing because regular server operation keeps the database tables sorted already, however 0.5->0.6 schema upgrade reordered some UIDs, revealing the issue.

@cbrake
Copy link

cbrake commented Jun 28, 2022

working here -- thanks!

@foxcpp foxcpp closed this as completed Jul 1, 2022
shift pushed a commit to shift/maddy that referenced this issue Jul 5, 2022
AppleSeed95 added a commit to AppleSeed95/sql-imap-v2 that referenced this issue Feb 4, 2024
Lack of UIDs sorting trips go-imap-mess algorithms
that expect sorted uidsMap (e.g. for binary search).

See foxcpp/maddy#512
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working. go-imap-sql Issue that is caused by a problem in go-imap-sql.
Projects
None yet
Development

No branches or pull requests

2 participants