com.apple.xpc.launchd & com.apple.mdworker.bundles pollute logs with errors

I made a clean install of Yosemite to MacBook Pro (13-inch, Early 2011), and restored documents and apps from TM backup, no problems so far, but I observe following repeating messages in system log and it concerns me, because apparently, launchd is trying to do something related to spotlight, but fails and this happens every 10 seconds.. I see no suspicious activity apart from too much CPU time spent on mds and mds_stores (but I guess it's due to fresh install, hence Spotlight needs to index everything...).


Any ideas where to dig?


21/10/2557 BE 2:11:43.811 PM com.apple.xpc.launchd[1]: (com.apple.mdworker.bundles[2654]) Could not find uid associated with service: 0: Undefined error: 0 502

21/10/2557 BE 2:11:43.835 PM com.apple.xpc.launchd[1]: (com.apple.mdworker.bundles) Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

21/10/2557 BE 2:11:53.838 PM com.apple.xpc.launchd[1]: (com.apple.mdworker.bundles[2655]) Could not find uid associated with service: 0: Undefined error: 0 502

21/10/2557 BE 2:11:53.838 PM com.apple.xpc.launchd[1]: (com.apple.mdworker.bundles) Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

[goes forever]

Posted on Oct 21, 2014 12:44 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 27, 2014 3:58 PM

I see, Dustmoo.. I thought the issue was caused by having that account with UID 502 in my main partition. So I dug it a bit more using your example. I actually couldn't find any mdworkers directory in /var. So I looked for the files owned by UID 502 (but it could be any other UID. One must check the last number in the error message, the one I underlined in my first post and use it instead of 502 in the following code):


cd /var

sudo find . -user 502 -exec ls -ld {} \;


This has been the output:


drwx------ 5 michele _spotlight 170 Oct 16 19:10 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502

drwx------ 2 michele _spotlight 68 Oct 16 19:10 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502/0

drwx------ 2 michele _spotlight 68 Oct 16 19:10 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502/C

drwx------ 2 michele _spotlight 68 Oct 16 19:10 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502/T


(michele is my username for UID 502)


So it was still in the /var/folder directory, but something related to or created by Spotlight one week ago. Not sure how it went there, since this was a fresh installation in that partition. It really looks like junk to me.


Just in case I removed the incriminated directory:


cd /private/var/folders/zz/

# I did some directory listing and other things just to check

sudo rm -r zyxvpxvq6csfxvn_n0000000000000

And rebooted. I can't really say if it changed anything because I had already made the new account, but it does look like the culprit.

63 replies
Question marked as Top-ranking reply

Oct 27, 2014 3:58 PM in response to Cyril Kay

I see, Dustmoo.. I thought the issue was caused by having that account with UID 502 in my main partition. So I dug it a bit more using your example. I actually couldn't find any mdworkers directory in /var. So I looked for the files owned by UID 502 (but it could be any other UID. One must check the last number in the error message, the one I underlined in my first post and use it instead of 502 in the following code):


cd /var

sudo find . -user 502 -exec ls -ld {} \;


This has been the output:


drwx------ 5 michele _spotlight 170 Oct 16 19:10 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502

drwx------ 2 michele _spotlight 68 Oct 16 19:10 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502/0

drwx------ 2 michele _spotlight 68 Oct 16 19:10 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502/C

drwx------ 2 michele _spotlight 68 Oct 16 19:10 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502/T


(michele is my username for UID 502)


So it was still in the /var/folder directory, but something related to or created by Spotlight one week ago. Not sure how it went there, since this was a fresh installation in that partition. It really looks like junk to me.


Just in case I removed the incriminated directory:


cd /private/var/folders/zz/

# I did some directory listing and other things just to check

sudo rm -r zyxvpxvq6csfxvn_n0000000000000

And rebooted. I can't really say if it changed anything because I had already made the new account, but it does look like the culprit.

Oct 27, 2014 8:30 PM in response to Michelasso

Great job, everybody,

Finding orphaned dirs belonged to user 502 in /var/ and deleting them helped to resolve the issue (after reboot)!


Queens-MBP-3:var queen$ sudo find . -user 502 -exec ls -ld {} \;

drwx------@ 3 502 wheel 102 Nov 12 2012 ./db/launchd.db/com.apple.launchd.peruser.502

-rw------- 1 502 wheel 461 Apr 10 2013 ./db/launchd.db/com.apple.launchd.peruser.502/overrides.plist

drwx------ 5 502 _spotlight 170 Oct 19 19:23 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502

drwx------ 2 502 _spotlight 68 Oct 19 19:23 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502/0

drwx------ 2 502 _spotlight 68 Oct 19 19:23 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502/C

drwx------ 2 502 _spotlight 68 Oct 19 19:23 ./folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight/502/T

-r--r--r-- 1 502 _uucp 11 Dec 2 2012 ./lock/LK.055.018.010

drwx------@ 2 502 wheel 68 Apr 13 2014 ./log/com.apple.launchd.peruser.502

-rw-------@ 1 502 mail 84736 Apr 9 2013 ./mail/user


After inspecting folders, I just sudo rm -rf them and all done.


So basically, Time Machine backed up dirs that belonged to all users on previous setup, and even though I explicitly asked TM not to restore user 502's account to this fresh Yosemite install, TM still restored some of 502's folders and Spotlight was stumbling over them (because user 502 did not exist anymore).


Hopefully, Apple techs pay attention to this issue.

Nov 26, 2014 6:36 AM in response to Cyril Kay

I had the same issue after upgrading to Yosemite.

The problem seems to be that there are files on the upgraded machine that are owned by a user that no longer exists, and this stops mds from indexing


This was how I fixed mine:


Note the number at the end of the error messages (probably 50x), For example 503 in the log record below:

com.apple.mdworker.bundles could not find uid associated with service: 0: Undefined error: 0 503


Follow the steps below, replacing my user id and group id numbers with your own !


1. Whilst logged in as your admin user, Launch Terminal

2. Type: id

3. Take note of the numbers after uid= and after gid=

4. This is your current user id and group id, for example: uid=504, gid=20


5. Type: sudo find / -uid 503

You will have to enter your admin password when prompted

This finds all files owned by the unknown user (for example the 503 taken from the error message in the log)


6. Type: sudo find / -uid 503 -exec chown -h 504:20 {} \; -print

You will have to enter your admin password when prompted

This finds all files owned by the unknown user (503 in this example) and changes the userid and group id to that of the current user (504 and 20 respectively in this example)


This will take some time to scan your entire disk (maybe 5 to 10 mins depending on how much data you have), but it will print what it changes.

Once it is done you can confirm it worked by re-running the scan for the unknown user:

Type: sudo find / -uid 503 -exec ls -l {} \;


Now you should get nothing back (apart from maybe an error about /dev/fd/x not being a directory, which you can ignore).


The mds process needs to be restarted to stop errors from still being logged as it seems to have the info cached somewhere.

Type:

sudo launchctl stop /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

sudo launchctl start /System/Library/LaunchDaemons/com.apple.metadata.mds.plist

Oct 27, 2014 11:37 AM in response to Dustmoo

Alright, I seem to have solved it without having to create a new user, (but thanks to @Michelasso for the tip!).


I started doing some investigation and found that there were some temp files for mdworker that were in a user 502 folder:


cd /private/var/folders

sudo find . | grep mdworkers


The above command will show you which temp directories have your com.apple.mdworker.bundle file. Mine looked something like this:


./6k/p4bx5l_x0154yj65gvnsl4jw0000gn/T/com.apple.mdworker.bundle

./y8/zdsf987dsf987sdfsd_s977cd_6kg97gs/C/com.apple.mdworker.bundle

./zz/zyxvpxvq6csfxvn_n00000b400002s/C/com.apple.mdworker.bundle


I then changed my directory into each folder and did and ls -l and found that in one the whole temp folder belonged to user 502


cd y8

ls -l


drwxr-xr-x 6 502 staff 204 July 27 11:04 zdsf987dsf987sdfsd_s977cd_6kg97gs


I also noted it was old.


So I removed that whole cache:


cd /private/var/folders

sudo rm -rf y8


I then had to restart (because my mac was locked in the respawn loop) and I have put her to sleep and woken her and so far all seems well.


For some reason launchd appears to be trying to spawn from old cache data.


Anyway, please test it out and see if it solves your problem.


Cheers!


Edit: clarification.

Oct 30, 2014 5:23 AM in response to William Paplham

William Paplham wrote:


Whatever deleting the folders does, it's only a temporary solution. Problem reappeared within 3 hours. Same folders are back.

Well, that simply means that something is regularly re-creating them. You may have a chance finding the process creating the files with wrong UID using "lsof". After identifying the incriminated files try running


lsof | grep <file to check>


like in this example:


lsof | grep /private/var/folders/wt/9h7d00q51nvfsqkvsdgxq0240000gn/T/com.apple.iChat

Messages 1610 admin 40u REG 1,5 512 1848404 /private/var/folders/wt/9h7d00q51nvfsqkvsdgxq0240000gn/T/com.apple.iChat/etilqs _uDh9zk5ow73vZNt

Messages 1610 admin 41u REG 1,5 4096 1848405 /private/var/folders/wt/9h7d00q51nvfsqkvsdgxq0240000gn/T/com.apple.iChat/etilqs _RDjd1IjXyGHnFI5

Messages 1610 admin 42u REG 1,5 512 1848406 /private/var/folders/wt/9h7d00q51nvfsqkvsdgxq0240000gn/T/com.apple.iChat/etilqs _vpzC2mqdnblrXqg

Messages 1610 admin 43u REG 1,5 4096 1848407 /private/var/folders/wt/9h7d00q51nvfsqkvsdgxq0240000gn/T/com.apple.iChat/etilqs _iUA3XeCrMKN6LQo


Then you can get the full path of the process doing


ps -ef | grep <PID>


Where <PID> (the process ID) is the first number you see in the previous output (1610 in my example). That may or may not work, depending on the process being still alive. If you're lucky and can find it update/uninstall/delete it or its correspondent application. Or check its preferences, whatever its needed to get a rid of those UIDs. You'll need to do some more digging.

Oct 31, 2014 5:15 PM in response to William Paplham

So after a clean install and over twelve hours, no mdworker issues.


In summary:

(A) Main system (Yosemite install over Maverick, which was a clean install several weeks earlier) - mdworker errors associated with 504 and 1104188992.


(B) Clean install of Yosemite on freshly wiped hard drive, using migration from Main system above - mdworker errors associated with 504


(C) Clean Clean install of Yosemite on freshly wiped hard drive, no migration, but iCloud data used to configure settings. NO ERRORs.


Since I have the same set of hard drives attached, mere presence of old system installations (not the boot drive) and backups aren't enough to trigger the mdworker issues.


So what triggers the errors?

Spotlight appears to be done indexing (at least it's not consuming CPU). Doesn't appear to be the cause.

Time machine would be running in case (B) since all my settings were migrated, whereas it's not set up in case (C). The time machine archive is where most of the 504 userid files were located. Also, when I do a find on 504 it appears the only locations are in the TM Machine backup.


I can't say for sure, but I don't think I reset the Time Machine backup after installing Yosemite. I don't remember what happened when I did the Mavericks clean install. It's possible that the Time Machine backup has references to users that don't exist anymore.


Is everyone seeing this issue using Time Machine.


Next step in troubleshooting is to reboot in Main system, wipe the Time Machine drive and start over and see what happens.

Nov 21, 2014 10:59 AM in response to David King1

Sure, it was pretty straightforward:


open the console, and check for the logs

I have a lot of entries like this:


com.apple.xpc.launchd[1]: (com.apple.mdworker.bundles[14231]) Could not find uid associated with service: 0: Undefined error: 0 501

com.apple.xpc.launchd[1]: (com.apple.mdworker.bundles) Service only ran for 0 seconds. Pushing respawn out by 10 seconds.


if you don't have these lines, you don't have the same problem.


The last number on the first line (501) will be different on your machine, it is the user ID of the files causing problems; Users start at 500, and each new user moves up by one, etc.

The problem happens when some files are owned by a user that doesn't exist.


So, find that number and then open a shell and type the following:


sudo find / -user 501 -exec ls -ld {} \;


don't forget to replace 501 by whatever number you found in the error.

it can take a while because this will scan the whole hard drive to find files owned by the problem owner.


after that, you can take all the files and change the ownership back to yourself


for this you can type the following:

sudo chown -R <yourusername:yourgroup> <files that were found>


In a previous post, Sonic Soul proposed to make the change automatic by doing this:

sudo find / -uid ERRORUID -exec chown -h YOURUID '{}' \+


It will work too, but I didn't go that route because I found some files that should have been owned by the system, in the /Library folder for example, so I preferred to do it manually.


After the find command doesn't return anything, reboot and it should work.

It has been like night and day since the fix!

Oct 24, 2014 9:09 PM in response to Dustmoo

After using Disk Utility to rebuild permissions, I restarted. I had to force quit my Macbook Pro (By holding the power button to force the shutdown) after it seemed get stuck shutting down.


After restarting, I canceled the dialog asking me if I wanted to reopen my applications because my computer shutdown because of a problem. And now all seems to be well. No more mdworker message in the logs and mdworker seems to be running (and apparently indexing the drive).


TL;DR I would recommend that you follow this procedure, it helped me:


  1. Use Disk Utility to rebuild your disk permissions.
  2. Save your work and quit your apps.
  3. Restart your Mac. (Force quit if you are still waiting after a couple of minutes)
  4. If after the restart Yosemite asks you if you want to reopen your Applications, "Cancel" to prevent your apps from reloading.
  5. All should be running normally.

Oct 27, 2014 6:38 AM in response to Cyril Kay

Yeah! I've found out what it is. I had the same identical annoying message spamming:


Oct 27 13:52:53 FlatMoon com.apple.xpc.launchd[1] (com.apple.mdworker.bundles): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

Oct 27 13:53:03 FlatMoon com.apple.xpc.launchd[1] (com.apple.mdworker.bundles[1141]): Could not find uid associated with service: 0: Undefined error: 0 502


Just look at the last number; 502. It is the UID of another user. Which is present in my main partition (I have Lion and Yosemite installed in two partitions because it is an unsupported MacBook2,1. Sorry Apple, it works!! 😝).


So I just created a new user in my Yosemite partition (I may actually need it), which automatically gets UID 502 and the awful spamming disappeared! If you don't have such user you may need to change the ownership of some incriminating files in Terminal with the command:


chown <your username> <file>


you may use the recursive option like in


chown -R <your username > /Users/<your username>


I hope this helps. ^_^

Oct 31, 2014 8:34 AM in response to William Paplham

You probably won't find any open files, since the event mentioned in the log messages are happening almost instantly (very fast).

The best way to find them is to use the command mentioned earlier:

sudo find / -user 504 -exec ls -ld {} \;


This could take a while. I collected the output to a file on the Desktop with the following command:

sudo find / -user 504 -exec ls -ld {} \; > ~/Desktop/foo.txt


I looked through my list, and most were just applications (with many-many nested folders inside).

So changing the owner to my user was relatively quick, and not so difficult.


As you are suspecting, I am also suspecting that these files are leftovers from previous system installs and HD migrations.

Since I fixed the owner on my list of files, the messages in the logs stopped.

Jan 10, 2015 7:09 PM in response to Cyril Kay

To add to the notes here. My experience:


1. Deleting the containing folder in private/var/folders/zz worked for me to eliminate extra UID 502. (In my case, I'm 501.)

2. Deleting the folder for UID 505 did not work. In fact, I think something created UID 505 after I deleted 502 but I can't remember. It looked like deleting worked but the folder appeared as soon as Spotlight made its calls.

3. I decided to get into the actual Info for the appropriate folder and the subfolders. You can see the issue right there: it says "fetching" under Sharing & Permissions and of course it never fetches because there is no such UID. Pretty bleeping obvious when you see it. Why it's there is a separate matter.

4. Changing ownership didn't work. I used chown but that didn't take so I went into Get Info and added myself as owner and deleted "fetching". As soon as Spotlight made its calls, "fetching" appeared. Note that I restarted after every one of these changes.

5. I decided to create a second user. Control-clicked on the name, clicked on the advance settings pop up and changed the UID from 502 to 505. Restarted yet again.

6. So far, when I check the actual Info for each folder, they all list (under Sharing & Permissions of course) me and my new user.


So my comment in the end is that something is spawning this need for another UID. It may be that sometimes that goes away, like maybe if you are already UID 502 instead of 501 and you delete 503 or 501 or something, but it seems persistent in the case where you are UID 501 until a new UID that fits the request is created. I will post a reply if this doesn't hold.


BTW, if you want to find the folder quickly, it's the zz folder whose name is all 0's. Look through all the levels inside: there's a folder named 0 and inside that is com.apple.spotlight and inside that are folders for each UID. You can unlock the folders by authenticating in the Get Info window for each. This might be easier for people unused to Terminal commands.


My guess is this problem is many more people would find this if they ever checked their Console.

Feb 22, 2015 9:31 PM in response to Michelasso

Worked perfect for me, exact same file name. This problem appeared when I transferred some iMessages from an older computer to my newer computer, and then Messages.app wouldn't start saying this error message: "The Messages database is being upgraded, please wait while it finishes or Quit Messages and relaunch it later." but it never finished or worked, and the Console message was "com.apple.xpc.launchd[1]: (com.apple.mdworker.bundles) Service only ran for 0 seconds. Pushing respawn out by 10 seconds." Since mdworker is related to Spotlight Indexing, and xpc is related to application integration, I assumed that Messages.app was trying to reindex my transferred iMessages and somehow couldn't do this because it failed. By eliminating /private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000 and rebooting the Console messages disappeared, and voilá, Messages works again with all the transferred messages in place, so this solution killed two birds with one stone, and so far has no downside, knock on wood. THANKS!

Nov 5, 2014 5:43 AM in response to wsrphoto

I don't think that the applications create fake IDs.

I think that the application was probably installed earlier, under a different ID. Different from your current user.

This could be due to several reasons. Like data migration, OS upgrade, etc.

I had failed HDs, where I had to recover user data from a dying HD.

I also did migration, migrating my previous user data onto a new computer.

I think most of you probably had the same, which probably caused all of these messages.

Deleting the applications, reinstalling the OS and turning off Spotlight is a bit much.


- If you just want the messages to stop, you can turn off Spotlight. It probably won't cause any other issue.

- Or you can fix the ownership with the commands posted by others.

- Or you can reinstall the OS, without migrating your data. That way the applications under the different user ID won't be migrated, and you won't have these messages.

But doing all 3 of these things is probably a bit too much.

Or lets say not necessary.

Nov 10, 2014 10:58 PM in response to wsrphoto

Used command to find all files associated with user 502 [which didn't exist]. Got a series of them. I manually changed ownership of the files to me and administrator and removed the icons in "get info" that were searching for the owner. Stopped these annoying console messages completely after restart of computer. Thanks for the terminal command to find user 502. The list made it easy to update the ownership. Thank you so much.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

com.apple.xpc.launchd & com.apple.mdworker.bundles pollute logs with errors

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.