Today while diagnosing some issues with high memory usage and general slowness on my normally quite peppy Macbook Pro, I finally discovered what may not only be causing issues with performance, but why Thunderbird sometimes goes nuts and corrupts its mailbox files.
The issue seems to relate to Spotlight searching, the mdworker process, and large mailbox files in Thunderbird.
sudo fs_usage -w -f filesys mdworker
I was able to see that the mdworker process was spending alot of time trying to constantly update/access/index files in the Thunderbird folder under Library in my home directory.
So, I went into System Preferences, then Spotlight, clicked on the Privacy tab, then hit the plus sign, and using Command-G, manually added the following folder to the do not index list:
This will prevent Spotlight from spending time indexing the Thunderbird mail files, which not only speeds up indexing if you have large mailboxes like me, but also helps avoid issues where Thunderbird will suddenly be unable to access mail folders (and sometimes, corrupt the folders).
So far, so good, and no more mailbox access errors in Thunderbird!