one of salt-master processes is defunct, why? How to prevent this?
The output of ps aux | grep 'salt-master':
root 23622 0.0 0.0 48640 1540 ? Ss Jan05 0:00 su -c salt-master
root 23640 0.0 0.0 730324 48160 ? Sl Jan05 1:25 /usr/bin/python /usr/bin/salt-master
root 23677 1.2 0.0 268620 55136 ? S Jan05 28:48 /usr/bin/python /usr/bin/salt-master
root 23687 0.0 0.0 273340 26568 ? Sl Jan05 0:07 /usr/bin/python /usr/bin/salt-master
root 23688 0.0 0.0 271560 20136 ? Sl Jan05 0:21 /usr/bin/python /usr/bin/salt-master
root 23693 0.4 0.0 817516 45916 ? Sl Jan05 10:44 /usr/bin/python /usr/bin/salt-master
root 23694 0.4 0.0 816344 44624 ? Sl Jan05 10:44 /usr/bin/python /usr/bin/salt-master
root 23697 0.3 0.0 0 0 ? Z Jan05 8:00 [salt-master] <defunct>
root 23700 0.4 0.0 813308 40796 ? Sl Jan05 11:07 /usr/bin/python /usr/bin/salt-master
root 23703 0.4 0.0 846580 74776 ? Sl Jan05 10:36 /usr/bin/python /usr/bin/salt-master
root 23706 0.3 0.0 0 0 ? Z Jan05 8:48 [salt-master] <defunct>
root 23707 0.2 0.0 0 0 ? Z Jan05 5:03 [salt-master] <defunct>
root 23712 0.3 0.0 0 0 ? Z Jan05 8:47 [salt-master] <defunct>
root 23730 0.0 0.0 13932 920 pts/136 S+ 13:39 0:00 grep --color=auto salt-master
The output of salt-master --versions-report:
Salt: 0.17.4
Python: 2.7.3 (default, Apr 10 2013, 06:20:15)
Jinja2: 2.6
M2Crypto: 0.21.1
msgpack-python: 0.1.10
msgpack-pure: Not Installed
pycrypto: 2.4.1
PyYAML: 3.10
PyZMQ: 13.0.0
ZMQ: 3.2.2
I don't see a defunct process in this list, but if there is one then there is a bug in catching exceptions in the worker procs. Is there anything in the master log? A stack trace?
@thatch45 Sorry, I ran wrong command (grep 'salt-master$') which filtered out defunct processes. I just updated ps output.
Here are recent un-handled exceptions:
2014-01-07 00:33:05,102 [salt.log.setup ][ERROR ] An un-handled exception was caught by salt's global exception handler:
SaltReqTimeoutError: Waited 60 seconds
Traceback (most recent call last):
File "/usr/bin/salt", line 10, in <module>
salt_main()
File "/usr/lib/pymodules/python2.7/salt/scripts.py", line 117, in salt_main
client.run()
File "/usr/lib/pymodules/python2.7/salt/cli/__init__.py", line 133, in run
for full_ret in cmd_func(**kwargs):
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 484, in cmd_cli
**kwargs):
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 1064, in get_cli_event_returns
jinfo = self.gather_job_info(jid, tgt, tgt_type, **kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 169, in gather_job_info
**kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 433, in cmd
**kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 228, in run_job
**kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 1216, in pub
payload = sreq.send('clear', payload_kwargs)
File "/usr/lib/pymodules/python2.7/salt/payload.py", line 193, in send
timeout * tried
SaltReqTimeoutError: Waited 60 seconds
---other info logs---
2014-01-07 08:02:30,441 [salt.log.setup ][ERROR ] An un-handled exception was caught by salt's global exception handler:
SaltReqTimeoutError: Waited 60 seconds
Traceback (most recent call last):
File "/usr/bin/salt", line 10, in <module>
salt_main()
File "/usr/lib/pymodules/python2.7/salt/scripts.py", line 117, in salt_main
client.run()
File "/usr/lib/pymodules/python2.7/salt/cli/__init__.py", line 133, in run
for full_ret in cmd_func(**kwargs):
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 484, in cmd_cli
**kwargs):
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 1064, in get_cli_event_returns
jinfo = self.gather_job_info(jid, tgt, tgt_type, **kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 169, in gather_job_info
**kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 433, in cmd
**kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 228, in run_job
**kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 1216, in pub
payload = sreq.send('clear', payload_kwargs)
File "/usr/lib/pymodules/python2.7/salt/payload.py", line 193, in send
timeout * tried
SaltReqTimeoutError: Waited 60 seconds
---other info logs---
2014-01-07 08:34:17,727 [salt.log.setup ][ERROR ] An un-handled exception was caught by salt's global exception handler:
SaltReqTimeoutError: Waited 60 seconds
Traceback (most recent call last):
File "/usr/bin/salt", line 10, in <module>
salt_main()
File "/usr/lib/pymodules/python2.7/salt/scripts.py", line 117, in salt_main
client.run()
File "/usr/lib/pymodules/python2.7/salt/cli/__init__.py", line 133, in run
for full_ret in cmd_func(**kwargs):
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 484, in cmd_cli
**kwargs):
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 1064, in get_cli_event_returns
jinfo = self.gather_job_info(jid, tgt, tgt_type, **kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 169, in gather_job_info
**kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 433, in cmd
**kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 228, in run_job
**kwargs)
File "/usr/lib/pymodules/python2.7/salt/client/__init__.py", line 1216, in pub
payload = sreq.send('clear', payload_kwargs)
File "/usr/lib/pymodules/python2.7/salt/payload.py", line 193, in send
timeout * tried
SaltReqTimeoutError: Waited 60 seconds
(let me know if this should be opened as a separate issue) I was having a similar issue as this, and getting a lot of defunct salt-master processes on 2014.1.4. I upgraded to 2014.1.7 and it doesn't seem to happen nearly as often now, but it does still happen occasionally.
To help reproduce it, I basically run something like this:
while /bin/true; do /usr/bin/salt --out=json --static --timeout=5 minionXX test.ping; sleep 1;done
If I run around 10 or so of those loops at once, at least one of my salt-master processes usually end up turning into a zombie process. The only error I can find in /var/log/salt/master is:
2014-07-31 13:31:06,730 [salt.client ][ERROR ] Salt request timed out. If this error persists, worker_threads may need to be increased.
There doesn't seem to be any uncaught exceptions that I can find in the log when it's set to DEBUG.
Any tips on how to track this down further? My current salt-master --versions-report:
Salt: 2014.1.7
Python: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
Jinja2: 2.2.1
M2Crypto: 0.20.2
msgpack-python: 0.1.13
msgpack-pure: Not Installed
pycrypto: 2.0.1
PyYAML: 3.10
PyZMQ: 2.2.0.1
ZMQ: 3.2.4
My worker_threads is set to 16 at the moment, and I can increase it further - but it basically decreases over time as more processes turn defunct.
Edit: Would a good feature request be something that monitors the worker threads and auto-restarts them if needed? I can look into that if it'd be accepted
@justyns That kind of a feature request does sound like it would be very good to have, I don't see why we wouldn't accept it.
As far as the defunct processes go, I think your issue is similar enough to the original issue that this is a good place for it. Thanks for the report!
Facing same isuue. Exexuting salt command through cron to collect data from minion. OS: Ubuntu 14.04
root 17392 0.0 0.6 890736 24268 ? Sl Sep07 0:19 /usr/bin/python /usr/bin/salt-master -d
root 17393 0.1 1.0 272200 38452 ? Sl Sep07 0:58 /usr/bin/python /usr/bin/salt-master -d
root 17407 0.0 0.6 301048 23688 ? Sl Sep07 0:04 /usr/bin/python /usr/bin/salt-master -d
root 17410 0.0 0.6 301580 25056 ? Sl Sep07 0:07 /usr/bin/python /usr/bin/salt-master -d
root 17413 0.0 0.5 300912 22732 ? Sl Sep07 0:10 /usr/bin/python /usr/bin/salt-master -d
root 17416 0.0 1.0 751556 39460 ? Sl Sep07 0:17 /usr/bin/python /usr/bin/salt-master -d
root 17417 0.0 1.0 751064 38944 ? Sl Sep07 0:18 /usr/bin/python /usr/bin/salt-master -d
root 17422 0.0 1.0 751056 38952 ? Sl Sep07 0:18 /usr/bin/python /usr/bin/salt-master -d
root 17425 0.0 1.0 751060 38960 ? Sl Sep07 0:17 /usr/bin/python /usr/bin/salt-master -d
root 17426 0.0 1.0 751056 39004 ? Sl Sep07 0:17 /usr/bin/python /usr/bin/salt-master -d
root 17432 0.0 1.0 751552 39480 ? Sl Sep07 0:17 /usr/bin/python /usr/bin/salt-master -d
root 17437 0.0 0.0 0 0 ? Z Sep07 0:01 [salt-master] <defunct>
root 17447 0.0 1.0 751056 38976 ? Sl Sep07 0:18 /usr/bin/python /usr/bin/salt-master -d
root 17458 0.0 1.0 751544 39456 ? Sl Sep07 0:18 /usr/bin/python /usr/bin/salt-master -d
root 17467 0.0 0.0 0 0 ? Z Sep07 0:02 [salt-master] <defunct>
root@xxx:/home/ubuntu# salt-master --versions-report
Salt: 2014.1.10
Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
Jinja2: 2.7.2
M2Crypto: 0.21.1
msgpack-python: 0.3.0
msgpack-pure: Not Installed
pycrypto: 2.6.1
PyYAML: 3.10
PyZMQ: 14.0.1
ZMQ: 4.0.4
Dealing with the same issue
OS: Debian 7
$ ps -ef | egrep salt-maste[r]
root 21573 1 0 14:06 ? 00:00:00 /usr/bin/python /usr/bin/salt-master -d
root 21574 21573 2 14:06 ? 00:00:06 /usr/bin/python /usr/bin/salt-master -d
root 21581 21573 0 14:06 ? 00:00:00 /usr/bin/python /usr/bin/salt-master -d
root 21582 21573 0 14:06 ? 00:00:00 /usr/bin/python /usr/bin/salt-master -d
root 21583 21573 0 14:06 ? 00:00:00 /usr/bin/python /usr/bin/salt-master -d
root 21588 21573 0 14:06 ? 00:00:00 [salt-master] <defunct>
root 21589 21573 0 14:06 ? 00:00:00 [salt-master] <defunct>
root 21590 21573 1 14:06 ? 00:00:03 [salt-master] <defunct>
root 21593 21573 0 14:06 ? 00:00:01 [salt-master] <defunct>
root 21594 21573 0 14:06 ? 00:00:00 [salt-master] <defunct>
$ sudo salt-master --versions-report
Salt: 2014.1.10
Python: 2.7.3 (default, Mar 13 2014, 11:03:55)
Jinja2: 2.6
M2Crypto: 0.21.1
msgpack-python: 0.1.10
msgpack-pure: Not Installed
pycrypto: 2.6
PyYAML: 3.10
PyZMQ: 13.1.0
ZMQ: 3.2.3
we're on 2014.1.10, and have the same problem - over time, all the processes end up going defunct. Have found no rhyme nor reason to this so far - thinking of just putting in a cron to bounce salt every 2hrs or something.
I would definitely be interested to know if any of you can reproduce this issue on 2014.7.0rc6 or the 2014.7 branch. Or even 2014.1.13, which is newly released.
We changed the process management in 2014.7 to recover from defunct processes. We have also seen this on older versions of ZeroMQ, things look better on zeromq 4
I've been seeing one defunct process pretty consistently on 2014.7 on Ubuntu 12.04
root@boucha:~# salt-master --versions-report
Salt: 2014.7.0rc6-13-g3101b75
Python: 2.7.3 (default, Feb 27 2014, 19:58:35)
Jinja2: 2.7.2
M2Crypto: 0.22
msgpack-python: 0.4.2
msgpack-pure: Not Installed
pycrypto: 2.6.1
libnacl: Not Installed
PyYAML: 3.11
ioflo: Not Installed
PyZMQ: 14.3.1
RAET: Not Installed
ZMQ: 4.0.4
Mako: Not Installed
root@boucha:~# ps aux | grep salt-master
root 15532 0.0 0.1 9384 924 pts/1 S+ 19:48 0:00 grep --color=auto salt-master
root 23421 0.0 0.0 42080 48 ? Ss Oct23 0:00 su -c salt-master
root 23422 0.0 0.7 295260 3816 ? S Oct23 0:01 /usr/bin/python /usr/local/bin/salt-master
root 23428 1.6 17.8 335408 89476 ? S Oct23 20:55 /usr/bin/python /usr/local/bin/salt-master
root 23429 0.0 0.5 220416 2552 ? Sl Oct23 0:00 /usr/bin/python /usr/local/bin/salt-master
root 23432 0.0 0.5 220892 2980 ? Sl Oct23 0:00 /usr/bin/python /usr/local/bin/salt-master
root 23471 0.0 9.3 378456 47124 ? Sl Oct23 0:04 /usr/bin/python /usr/local/bin/salt-master
root 23474 0.0 0.7 295260 3528 ? S Oct23 0:00 /usr/bin/python /usr/local/bin/salt-master
root 23475 0.0 4.1 698056 20704 ? Sl Oct23 0:09 /usr/bin/python /usr/local/bin/salt-master
root 23476 0.0 2.8 697184 14436 ? Sl Oct23 0:08 /usr/bin/python /usr/local/bin/salt-master
root 23477 0.0 4.0 698100 20216 ? Sl Oct23 0:09 /usr/bin/python /usr/local/bin/salt-master
root 23478 0.0 3.7 779236 19028 ? Sl Oct23 0:09 /usr/bin/python /usr/local/bin/salt-master
root 23480 0.0 2.6 779564 13428 ? Sl Oct23 0:08 /usr/bin/python /usr/local/bin/salt-master
root 23486 0.0 0.9 672116 4984 ? Sl Oct23 0:00 /usr/bin/python /usr/local/bin/salt-master
root 24112 0.0 0.0 0 0 ? Z Oct23 0:00 [salt-master] <defunct>
root@boucha:~#
This happens after I come back to the vm after a while. At least several hours, maybe a day. I haven't timed it exactly.
We actually found the issue for us. Salt for some strange reason keeps old run files for a while (by default 24 hrs) in some dir like /var/cache/salt/master/run. Those were taking all the inodes. We had none left. So no new files could be written. Setting that setting to 1 seems to have fixed the defunct problem
Thanks, Darren
Sent from my iPhone
On 25 Oct 2014, at 04:28, Colton Myers [email protected] wrote:
I would definitely be interested to know if any of you can reproduce this issue on 2014.7.0rc6 or the 2014.7 branch. Or even 2014.1.13, which is newly released.
— Reply to this email directly or view it on GitHub.
We're seeing the same issue constantly since the version 2014 releases on debian wheezy. We also set keep_jobs to 1 hour after upgrading to 2014* but with no effect.
$ salt-master --versions-report
Salt: 2014.1.13
Python: 2.7.3 (default, Mar 13 2014, 11:03:55)
Jinja2: 2.7.1
M2Crypto: 0.21.1
msgpack-python: 0.1.10
msgpack-pure: Not Installed
pycrypto: 2.6
PyYAML: 3.10
PyZMQ: 13.1.0
ZMQ: 4.0.4
I am also experiencing this, but with 2014.7. There are no exceptions in the log and nothing abnormal (that I could see) in INFO/DEBUG levels.
ps -ef | grep salt-master
root 11105 1 0 13:39 ? 00:00:01 /usr/bin/python /usr/bin/salt-master -d
root 11106 11105 2 13:39 ? 00:00:11 /usr/bin/python /usr/bin/salt-master -d
root 11107 11105 0 13:39 ? 00:00:00 /usr/bin/python /usr/bin/salt-master -d
root 11110 11105 0 13:39 ? 00:00:00 /usr/bin/python /usr/bin/salt-master -d
root 11148 11105 0 13:39 ? 00:00:00 /usr/bin/python /usr/bin/salt-master -d
root 11151 11105 0 13:39 ? 00:00:00 /usr/bin/python /usr/bin/salt-master -d
root 11152 11151 1 13:39 ? 00:00:08 /usr/bin/python /usr/bin/salt-master -d
root 11153 11151 1 13:39 ? 00:00:06 /usr/bin/python /usr/bin/salt-master -d
root 11154 11151 1 13:39 ? 00:00:07 /usr/bin/python /usr/bin/salt-master -d
root 11155 11151 1 13:39 ? 00:00:06 /usr/bin/python /usr/bin/salt-master -d
root 11156 11151 1 13:39 ? 00:00:07 /usr/bin/python /usr/bin/salt-master -d
root 11157 11151 0 13:39 ? 00:00:00 /usr/bin/python /usr/bin/salt-master -d
root 14685 11153 0 13:45 ? 00:00:00 [salt-master] <defunct>
root 14730 11154 0 13:45 ? 00:00:00 [salt-master] <defunct>
root 14766 11155 0 13:45 ? 00:00:00 [salt-master] <defunct>
root 14778 11156 0 13:45 ? 00:00:00 [salt-master] <defunct>
root 14800 11152 0 13:45 ? 00:00:00 [salt-master] <defunct>
salt --versions-report
Salt: 2014.7.0
Python: 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
Jinja2: 2.2.1
M2Crypto: 0.20.2
msgpack-python: 0.1.13
msgpack-pure: Not Installed
pycrypto: 2.0.1
libnacl: Not Installed
PyYAML: 3.10
ioflo: Not Installed
PyZMQ: 14.3.1
RAET: Not Installed
ZMQ: 3.2.4
Mako: Not Installed
@thatch mentioned using zeromq4, but I don't see that package on epel so I'm using 3.x.
I still have some minions that are running 2014.1.x connecting to this master. Tomorrow I'll upgrade those and see if the defunct processes persist.
Removing 2014.1 minions did not alleviate the issue. However, I have been able to observe that these processes go defunct approximately every 30-60 minutes.
# ps -ef | grep salt-master | grep defunct
root 25744 25068 0 07:32 ? 00:00:00 [salt-master] <defunct>
root 25834 25070 0 07:32 ? 00:00:00 [salt-master] <defunct>
root 25984 25069 0 07:32 ? 00:00:00 [salt-master] <defunct>
root 26001 25067 0 07:32 ? 00:00:00 [salt-master] <defunct>
root 26046 25071 0 07:32 ? 00:00:00 [salt-master] <defunct>
# ps -ef | grep salt-master | grep defunct
root 29227 25067 0 08:05 ? 00:00:00 [salt-master] <defunct>
root 29245 25069 0 08:05 ? 00:00:00 [salt-master] <defunct>
root 29302 25071 0 08:05 ? 00:00:00 [salt-master] <defunct>
root 29329 25070 0 08:06 ? 00:00:00 [salt-master] <defunct>
root 29344 25068 0 08:06 ? 00:00:00 [salt-master] <defunct>
# ps -ef | grep salt-master | grep defunct
root 632 25070 0 08:58 ? 00:00:00 [salt-master] <defunct>
root 649 25067 0 08:58 ? 00:00:00 [salt-master] <defunct>
root 715 25071 0 08:58 ? 00:00:00 [salt-master] <defunct>
root 742 25068 0 08:59 ? 00:00:00 [salt-master] <defunct>
root 29245 25069 0 08:05 ? 00:00:00 [salt-master] <defunct>
any solutions?
[root@puppet ~]# salt 'linux.autohome.com' test.ping
Salt request timed out. The
master is not responding. If this error persists after verifying the master is up, worker_threads may need to be increased.
[root@puppet ~]# salt 'linux.autohome.com' test.ping --out=json --static --timeout=5
[ERROR ] An un-handled exception was caught by salt's global exception handler:
SaltClientError: Salt request timed out. The master is not responding. If this error persists after verifying the master is up, worker_threads may need to be increased.
Traceback (most recent call last):
File "/usr/bin/salt", line 9, in <module>
load_entry_point('salt==2015.8.0', 'console_scripts', 'salt')()
File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 454, in salt_main
client.run()
File "/usr/lib/python2.7/site-packages/salt/cli/salt.py", line 80, in run
batch = salt.cli.batch.Batch(self.config, eauth=eauth, quiet=True)
File "/usr/lib/python2.7/site-packages/salt/cli/batch.py", line 34, in __init__
self.minions, self.ping_gen = self.__gather_minions()
File "/usr/lib/python2.7/site-packages/salt/cli/batch.py", line 56, in __gather_minions
for ret in ping_gen:
File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 655, in cmd_iter
**kwargs)
File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 297, in run_job
raise SaltClientError(general_exception)
SaltClientError: Salt request timed out. The master is not responding. If this error persists after verifying the master is up, worker_threads may need to be increased.
Traceback (most recent call last):
File "/usr/bin/salt", line 9, in <module>
load_entry_point('salt==2015.8.0', 'console_scripts', 'salt')()
File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 454, in salt_main
client.run()
File "/usr/lib/python2.7/site-packages/salt/cli/salt.py", line 80, in run
batch = salt.cli.batch.Batch(self.config, eauth=eauth, quiet=True)
File "/usr/lib/python2.7/site-packages/salt/cli/batch.py", line 34, in __init__
self.minions, self.ping_gen = self.__gather_minions()
File "/usr/lib/python2.7/site-packages/salt/cli/batch.py", line 56, in __gather_minions
for ret in ping_gen:
File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 655, in cmd_iter
**kwargs)
File "/usr/lib/python2.7/site-packages/salt/client/__init__.py", line 297, in run_job
raise SaltClientError(general_exception)
salt.exceptions.SaltClientError: Salt request timed out. The master is not responding. If this error persists after verifying the master is up, worker_threads may need to be increased.
I'm very confident that we have solved this issue with the process management code in 2015.5 and above. I haven't seen nor heard of an issue like this since then.