Bugs & Fixes: Solving a Mac Pro sleep problem
I’ve been having a sleep problem. Not personally. But with my Mac Pro.
Consider this column a work in progress. I’m still not exactly sure what is going on, but I’m getting close to figuring it out.
The problem is that, after I manually select the Sleep command for my 2009 Mac Pro, it often (but not always) goes to sleep and immediately reawakens. If I then select Sleep a second time, the Mac successfully goes to sleep and stays there.
This symptom can be especially irritating if I select Sleep and leave my office before waiting to see if the machine truly goes down for its nap. I return some time later and find that the Mac is still very much awake.
Why is this happening?
I investigated numerous possible causes and ruled most of them out. For example, I can confirm that it is not due to a Bluetooth device waking up my Mac. I eventually narrowed the cause down to two, possibly interacting, factors.
The first factor is Mac OS X’s Wake on Demand feature. This works, in combination with an AirPort Base Station or Time Capsule, to allow other devices on a network to temporarily wake up a sleeping device and perform a requested action. To enable this feature, you go to the Energy Saver System Preferences pane and select “Wake for network access.” I had done this for my Mac Pro.
Apple notes that, even without a specific network request, “Macs that have Wake on Demand enabled will occasionally wake for a brief time, without lighting the screen, in order to maintain registrations with the Bonjour Sleep Proxy.” The Mac should then return to sleep. An alert message, warning you that this can happen, appears when you first enable the feature in Energy Saver:
According to posts in Apple’s Discussions forums, this “maintenance” waking will happen about once every two hours. I checked my Mac Pro’s Console log and confirmed that this is so. Messages such as the following appear about every two hours when the Mac is asleep:
8/25/10 2:22 20 PM Aug 25 kernel Wake reason = RTC
8/25/10 2:22 20 PM Aug 25 kernel RTC: maintenance alarm 2010/8/25 21:22:19, sleep 2010/8/25 19:35:08
8/25/10 2:22 20 PM Aug 25 kernel System Wake
RTC stands for Real Time Clock. A “maintenance alarm” is how Console describes the periodic “Wake on Demand” checks. If I disable “Wake on Demand,” these messages stop.
This feature, however, should not cause my Mac Pro to wake up immediately after putting it to sleep. And it doesn’t. At least not by itself. This brings me to the second factor: Scheduled wake ups. If you again go to the Energy Saver System Preferences pane and click the Schedule button, a sheet drops down. From here, you can schedule a time to automatically wake up your Mac. I’ve set my Mac Pro to wake up every day at 8:10 AM:
In the Mac’s Console logs, these scheduled wake ups correspond to an RTC alarm message, but not a “maintenance alarm.” Here is an example (note that 15:10:00 is GMT time for 8:10:00 PT):
8/27/10 8:10 01 AM Aug 27 kernel Wake reason = RTC
8/27/10 8:10 01 AM Aug 27 kernel RTC: alarm 2010/8/27 15:10:00, sleep 2010/8/27 14:49:48
8/27/10 8:10 01 AM Aug 27 kernel System Wake
So far, everything appears fine. The critical Console message is the one that appears after my Mac Pro spontaneously and erroneously re-awakens:
8/26/10 9:38 03 AM Aug 26 kernel Wake reason = RTC
8/26/10 9:38 03 AM Aug 26 kernel RTC: alarm 2010/8/26 15:10:00, sleep 2010/8/26 16:38:02
8/26/10 9:38 03 AM Aug 26 kernel System Wake
It looks just about the same as a scheduled wakeup message, with one exception. The 15:10:00 time is earlier than 16:38:02, the time when I manually put the Mac Pro to sleep. If my Mac Pro could speak, I imagine it might say: “Oops. I was supposed to wake up at 15:10. It’s now 16:38 and I’m asleep. I’m late. I better wake up immediately.” And it does.
Having done this, the schedule is updated so that it is now correctly set to wake up automatically at 15:10 the next morning. That’s why, if I put the Mac to sleep a second time, it stays asleep.
The question is: How does this time mix-up occur? Here is where I am still uncertain. The scheduled wake-up day and time is stored in a file called com.apple.AutoWake.plist, located in /Library/Preferences/SystemConfiguration. It’s possible that something is amiss with this file and that it is not always updated properly. However, I’ve checked the file on my Mac Pro and it seems to be in good working order. Still, according to some reports I have read, it might help to delete this file and allow the Mac to create a new one. I haven’t tried this as yet.
I did turn off the “Wake on Demand” feature two days ago. Since doing this, I have not had a “re-wake” error. I don’t take this as definitive proof, but it suggests that the two factors may be related. One possibility is that there is a bug such that, when both Wake on Demand is enabled and an automatic wake is scheduled, the symptom occurs. If so, this means that if I re-enable Wake on Demand and turn off the scheduled wake-up, the symptom should similarly vanish. I have not yet had time to confirm this. Progress is made difficult by the fact that the symptom only occurs sporadically.
I’ll continue to investigate. If I learn more, I’ll let you know.