Why does Spotlight keep reindexing my system after updating to Lion?
Since I installed Lion, the Spotlight database keeps reindexing (which is taking several hours). It does this at least every second day.
Are any other users experiencing this problem with Lion (i.e. is it just a 10.7.0 bug)? If not, how can I diagnose what is causing it - I see no suspicious entries in Console?
Just being able to reset the spotlight history and have it rebuild would be nice to know.
Solution 1:
I, too, had the reindexing problem happening after I upgraded to Lion. However the problem didn't exist for every user, just for the one that was using FileVault 1.
After a few weeks I got overfrustrated and ran… †
$ sudo mdutil -a -i off
… in Terminal — and the same minute I realised that the setting was applied system–wide. I shrugged and enjoyed a few hours worth of reindexing–free session after which I decided to turn Spotlight back on, as it is crucial to my workflow on other user accounts; so:
$ sudo mdutil -a -i on
And while I was at it, I decided to erase the old index and rebuild new from scratch with:
$ sudo mdutil -aE
I did this about a month ago and I haven't encountered "useless" reindexing since. I'm happily surprised because fixing the issue was merely a coincidence.
So, have you tried turning it off and on again?
†) the -a
flag will apply the action to all volumes which might not be something you want — and actually wasn't what I wanted either, but I just wanted to go blitzkrieg on the issue.
Solution 2:
I figured this out. One of the spotlight plugins was causing errors, which closer scrutiny of the Console log revealed.
I found out which app was causing the problem by looking in
/Library/Logs/DiagnosticReports
There I found several crash reports from mdworker (the backend to Spotlight). All crashes were caused by the same app plugin. I have now deleted that plugin from my system.
Solution 3:
New theory: my system drive keeps running low on space — sometimes down to only a few hundred MB free. When the OS detects this situation, it deletes the Spotlight indices. When I free up space again, it has to rebuild the indices.