Monday, October 03, 2011

Lion Mail Crashes When Searching

I’ve had a very frustrating problem with searching in Mac OS X 10.7 “Lion” Mail app since I upgraded. After installing Lion after release, searching in Mail using the keywords like “subject:” and “from:” weren’t being honored and the search results weren’t correct. I was able to resolve this by one of the Apple engineers pointing me towards a bad index and rebuilding my mailbox indexes. This resolved that issue.

After that I started to see a problem where randomly when I’d type anything into the Mail search field the app would freeze, then crash. I was able to do the searches through Spotlight with the keywords, but it was kind of annoying. This became a consistent, reproducable problem after Mac OS X 10.7.1 was installed.

Earlier today I was able to talk again with one of the Apple engineers and he pointed me towards a corruption problem with the “Previous Recipients” list in Mail. Sure enough when I’d try “Window -> Previous Recipients” the window wouldn’t show, and when it finally did after a number of times and restarts, it was only half drawn on the screen.

Since I wasn’t able to clear this list using the GUI, I dig around and found I could do it from Terminal. Since doing this I’m able to search in Mail now without crashing, and it’s so nice

To fix this we need to open the “Previous Recipients” database, which is a sqlite database. First, close your Mail app if it’s running. Next, open Terminal and type:

sqlite3 ~/Library/Application Support/AddressBook/MailRecents-v4.abcdmr

Next we need to clear out all of the “Previous Recipients” addresses in this database. To do that, type:

DELETE FROM ZABCDMAILRECENT

To exit sqlite press CONTROL + Z.

Open Mail and you should now be able to search!

3 comments:

Anonymous said...

I tried doing this but sqlite is giving me Error: disk I/O error. Any idea why that might be happening, or how to fix this another way?

Troy said...

That sounds like a problem with hardware and not software. I'd contact AppleCare

Unknown said...

Troy - thanks so much for this... It's the first thing that's worked for me. Let's hope it continues!

The other comment I had was that sqlite wanted an underscore between "Application" and "Support". It's a space in the folder name, but sqlite didn't like that!