I never had this problem with any version of Yosemite:
10.10.0 → 10.10.5
Today I installed "Security Update 2016-004 10.10.5", and a few minutes after this update terminated
successfully, I tried a simple:
> Restart...
and it failed with the error message found in /var/log/system.log :
Attempt to start a: Restart, AFTER a Restart was already past the point where logout can change types
Since I was locked in this situation and couldn't allow to crash a production system like this, I took advantage of this situation and wasted time to investigate it in depth.
A terminal opened with atop -o cpurunning bringed naked the clear culprit, I had a few tenths of mdworker running.
To better scale the size of the problem, I ran:
ps ax | grep mdworker | wc -l
which replied me with:
47
and some other varying values always bigger than 40.
To be sure I compared with what was actually running on another Yosemite 10.10.5 on which I didn't applied
the Security Update 2015-006. And the result of the same command was:
2
I guessed that the genius Spotlight was harvesting under cover an external backup disk I had left connected.
This was the origin of all these mdworker running and blocking any attempt to unmount the disk to perform
a clean shutdown.
The following command:
mdutil -s -a
confirmed me that I had caught the real culprit.
When I had a possibility to restart the system without killing any work in progress, I opened a Terminal and entered
the following command:
/usr/bin/sudo reboot
Once rebooted, I configured Spotlight to stay quieter, and since, everything looks fine. A reboot is achieved within less than 2 minutes.