Yep, sorry, I haven't updated the readme since GitHub decided to shut
off gem building without warning. You can install the latest Larch dev
gem from Gemcutter:
gem install larch --pre -s http://gemcutter.org
- Ryan
Sounds like a bug in the dev build. I'll look into it.
> Then when I removed the --exclude INBOX I found that the
> Net::IMAP::NoResponseError has gone away if I copy from a big folder
> (tens of thousands of messages) to a new or empty folder, but if I
> copy to a folder that already has tens of thousnds of messages, even
> if I copy from a folder that only has two messages, the
> Net::IMAP::NoResponseError is still there. Here is the end of the log
> output from that:
>
> [info] US...@imap.example.com: INBOX.ham: fetching message headers 1
> through 2...
> [debug] US...@gmail.com@imap.gmail.com: ham: getting mailbox status
> [debug] US...@gmail.com@imap.gmail.com: ham: examining mailbox
> [info] US...@gmail.com@imap.gmail.com: ham: fetching latest message
> flags...
> [debug] US...@gmail.com@imap.gmail.com: ham: removing 323 deleted
> messages from the database...
> [info] US...@gmail.com@imap.gmail.com: ham: fetching message headers
> 10937 through 42979...
> [info] US...@gmail.com@imap.gmail.com: Net::IMAP::NoResponseError: Some
> messages could not be FETCHed (Failure) (will retry)
Ugh. The "Some messages could not be FETCHed" error is a bug (or at
least some very bad behavior) in Gmail's IMAP interface. You can read
about it here (among other places):
http://www.google.com/support/forum/p/gmail/thread?tid=3cc1c96a8f210bd3&hl=en
The leading theory is that this error is caused by a message that
Gmail's web interface handles just fine, but which for some reason
causes their IMAP interface to choke. Every time an IMAP client sends
a FETCH command that includes this message, Gmail returns the error
above. The only solution seems to be to narrow down which message is
causing the problem and either delete it or move it to another folder.
I'd like to be able to have Larch automatically handle this problem,
but since the exact cause is unknown (which means I can't
intentionally create the problem in order to test solutions), I don't
have a fix for it right now.
If you're doing a one-time transfer, then a temporary workaround would
be to have Larch transfer mail to a new Gmail folder, then manually
move those messages into the desired folder using the Gmail web
interface.
- Ryan
> I had to close the GMail tab to get to stop the repeating error, then
> I searched for the date range again and changed the label of the
> message to a new one I created. Now that is the only mail message in
> that folder and clicking on it to display it still produces the error.
>
> It certainly seems like Google's problem. Would a correct workaround
> be for Larch to ignore the error, missing just the one email, given
> that all the other headers do fetch ok?
Thanks for the additional analysis and details. Given what you've
described, it does seem like the best thing for Larch to do is to
ignore messages that trigger this error. The hard part, though, is
identifying them. When Larch scans headers in a folder, it does a
batch fetch of up to 1024 headers at a time, and the entire batch will
fail with this error if just one of the messages is corrupt. In order
to find the corrupt message, Larch would have to gradually decrease
the size of the batch until the fetch succeeds and the culprit is
identified, which could take a while.
Still, it'd be better for Larch to work around the problem slowly than
not work around it at all, so this is probably what I'll implement.
The only blocker now is that I'll need to be able to reproduce the
problem myself before I can test a solution for it. I don't currently
have any Gmail test mailboxes that are experiencing this problem, and
I haven't yet figured out a way to intentionally create a corrupt
message that will trigger it.
I don't suppose you'd be willing to try forwarding me your corrupt
message? Not sure if it'll even be possible if the web UI chokes on
the message, but it's worth a shot. Of course, I'll understand if
you'd prefer not to for privacy reasons.
- Ryan
I found that I could change the labels on the message in the web
interface. I can't open it, which means that I can't save it as a file
or forward it. Some discussion of the problem talked about downloading
messages using POP3. I don't know if they were successful at downloading
the offending message, or if the POP3 download was a way of getting all
messages except that one. The disadvantage of downloading everything as
POP3 is losing the labels. I found no way to download just one message
via POP3. The only POP3 choices I seem to have are to set the Gmail
account to let me download new messages that are incoming after I make
the setting, or else download all messages.
I created a new label for it to isolate it, and I'm in the process of
using larch to copy all the other folders to another gmail account. Then
I'll delete all the other messages from the original account and see if
POP3 works to read it. When that fails, I suppose I could change the
password on the account and trust you with access to it long enough to
debug this thing, but I hope I can manage to get the message on a new
dummy Gmail account exhibiting the problem so I can just hand that to
you. The larch synching will take a while longer as there are over
70,000 messages to transfer.
Now when I restart the larch run it dies with an illegal instruction
error at the same place each time. The output looks like this (editing
out the real usernames and the [time stamp] and [info] om each line):
$ larch "gmailtogmail2"
U...@imap.gmail.com: connecting...
U...@imap.gmail.com: connected on port 993 using SSL
U...@imap.gmail.com: authenticated using PLAIN
U...@imap.gmail.com: connecting...
U...@imap.gmail.com: connected on port 993 using SSL
U...@imap.gmail.com: authenticated using PLAIN
copying messages from imap.gmail.com/f1 to imap.gmail.com/f1
copying messages from imap.gmail.com/f2 to imap.gmail.com/f2
U...@imap.gmail.com: f2: fetching latest message flags...
U...@imap.gmail.com: f2: fetching latest message flags...
copying messages from imap.gmail.com/spamtrap to imap.gmail.com/f3
U...@imap.gmail.com: f3: fetching latest message flags...
U...@imap.gmail.com: f3: fetching latest message flags...
U...@imap.gmail.com: f3: fetching message headers 18680 through 18698...
Illegal instruction
I'm going to try to exclude the folder that I called f3 in the above log
and see if I can get everything else backed up and then see what is
going on with that folder.
Adding the exclude for [Gmail took care of that problem, and the copy
completed, without the folder that led to the illegal instruction.
I then removed the exclude for that folder, which now is the only one
not fully synched, and that repeated the illegal instruction error.
Using openssl for telnet access to imap I did a fetch 1:n rfc822.header
on that folder to verify that there are no fetch failures in that
folder. So that doesn't explain the illegal instruction trap.
I now have deleted the larch.db file in case the problem is related to
larch caching the flags for the problematic email that I have moved to
its own folder, and I'm running larch again now to see what happens.
This testing has revealed another bug: In config.yaml I have a line
verbosity: debug
but the output only shows info level unless I add -V debug to the
command line.
This could indicate a bug in Larch's DB code. The "Illegal
instruction" error certainly isn't coming from Gmail or from the Ruby
Net::IMAP lib itself. Since it's not accompanied by a Ruby stack trace
and since deleting larch.db fixes it, my best guess is that it's
happening somewhere in the native SQLite adapter.
Some quick searching reveals that SQLite tends to throw illegal
instruction errors and die when it runs out of memory, so we may have
a memory exhaustion issue here, which implies that either Larch is
operating on the DB in a memory-inefficient way, or you're running
Larch on a machine with very limited memory.
- Ryan
Definitely sounds like a Larch problem then. I'll investigate.
> Also, the issue of not copying most of the folders was consistent. I
> moved the server configuration portion of config.yaml into default
> then used a bash command line like
> for i in f1 f2 f3 ; do larch default -F "$i" -T "$i" ; done
> and that seems to be working fine copying all the messages that were
> skipped over by the configuration I posted earlier in this thread.
Are the folders that aren't being copied subscribed? If not, it's
possible that the "all" config option is not being respected properly.
I'll look into this as well.
- Ryan
Just realized I forgot to respond to this (it's been a busy day).
The method Larch uses is (I think) the same one used by Thunderbird
and most, if not all, other IMAP clients. Each time Larch opens a
mailbox, it requests a complete list of all the message UIDs and flags
in that mailbox. Any UIDs that are in the database but not in the
server's response have been deleted since Larch last saw them, so
Larch deletes them from the database to keep things in sync.
Assuming the server is following the spec and not reassigning UIDs,
this should correctly detect any messages in the mailbox that have
been removed, regardless of their position in the mailbox. If you run
Larch with --verbosity debug, you should see a message like "removing
{number} deleted messages from the database..."
Note that a message that has been flagged \Deleted on the server is
not actually considered removed and will still exist in the mailbox
(and in Larch's database) until it's actually expunged from the
mailbox. This may be what you're seeing.
- Ryan
Certainly sounds like there could be a problem in the mailbox scanning
code in the dev build. I'm keeping track of the issues you've
reported, but I won't be able to investigate them in depth until this
weekend at the earliest.
- Ryan