Saturday, April 24, 2010

Yum Thread Error on Virtual Private Servers (VPS)

If you see the following error below, it is a memory resource issue triggered by fastestmirror plugin of yum on VPS systems. So far, I have observed this to happen on Linux (RHEL) and CentOS VPS under OpenVZ virtual server.

#yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Traceback (most recent call last):
File "/usr/bin/yum", line 29, in ?
yummain.user_main(sys.argv[1:], exit_code=True)
File "/usr/share/yum-cli/", line 309, in user_main
errcode = main(args)
File "/usr/share/yum-cli/", line 178, in main
result, resultmsgs = base.doCommands()
File "/usr/share/yum-cli/", line 345, in doCommands
File "/usr/lib/python2.4/site-packages/yum/", line 101, in _getTs
File "/usr/lib/python2.4/site-packages/yum/", line 112, in _getTsInfo
pkgSack = self.pkgSack
File "/usr/lib/python2.4/site-packages/yum/", line 661, in
pkgSack = property(fget=lambda self: self._getSacks(),
File "/usr/lib/python2.4/site-packages/yum/", line 501, in _getSacks
File "/usr/lib/python2.4/site-packages/yum/", line 232, in populateSack
File "/usr/lib/python2.4/site-packages/yum/", line 79, in doSetup'postreposetup')
File "/usr/lib/python2.4/site-packages/yum/", line 179, in run
func(conduitcls(self, self.base, conf, **kwargs))
File "/usr/lib/yum-plugins/", line 181, in postreposetup_hook
all_urls = FastestMirror(all_urls).get_mirrorlist()
File "/usr/lib/yum-plugins/", line 333, in get_mirrorlist
File "/usr/lib/yum-plugins/", line 376, in _poll_mirrors
File "/usr/lib/python2.4/", line 416, in start
_start_new_thread(self.__bootstrap, ())
thread.error: can't start new thread

The error can be easily reproduced if the following conditions are met.

1. Yum is installed on a VPS. I used Open VZ virtual server.
2. VPS alloted memory is between 512MB and below. I used 192MB memory allocation to simulate.
3. You're running mysql, httpd or other application with multi-processing / multi-threading having a relatively substantial memory heap size per process / thread. It was originally observed with mysql running.

You can easily deduce that the error is related to the following.

1. Memory resource available on the VPS is insufficient to allot for new threads for yum's fastestmirror plugin.
2. Some daemonized applications are consuming all the memory resources (i.e mysql, httpd etc)

Now that we know the root causes, we can fix or bypass the error by doing any of the following.

1. Turn off applications that allocate too much memory.

# /etc/init.d/mysqld stop
# /etc/init.d/httpd stop

2. Increase memory resources to a more workable level. I never encountered this with VPS setups with at least 768MB
3. Bypass fastestmirror plugin. Yum works without this.
To temporarily bypass it, do,
# yum --disableplugin=fastestmirror [yum action you need to perform]

Or to permanently disable fastestmirror,
#vi /etc/yum/pluginconf.d/fastestmirror.conf
Change enabled=1 to enabled=0, then save (ESC + wq).
After which, you can run yum normally.

This error was also reported as a yum bug and was already marked as resolved. See ticket #70
  • Related Links Widget for Blogspot

No comments: