Linux 进程永久停留在 D 状态

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20423521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:33:43  来源:igfitidea点击:

Process permanently stuck on D state

linuxubuntuprocesshard-drive

提问by Dr Craig

I have an issue with some processes stuck in a D state on Ubuntu 10.04.3 LTS.

我在 Ubuntu 10.04.3 LTS 上遇到一些进程卡在 D 状态的问题。

They have been in this state since Nov the 5th (today being December 6th). I understand these are uninterruptible sleep states often related to waiting for data from hardware such as a hard disk. This is a production server so rebooting is a very last resort, is anyone able to shed any light on what these processes might be?

自 11 月 5 日(今天是 12 月 6 日)以来,他们一直处于这种状态。我知道这些是不间断的睡眠状态,通常与等待来自硬件(如硬盘)的数据有关。这是一个生产服务器,因此重新启动是最后的手段,有人能够了解这些进程可能是什么吗?

This is the output for the D state items from ps -aux

这是 D 状态项的输出 ps -aux

www-data 22851  0.0  0.0      0     0 ?        D    Nov05   0:00 [2637.64]
www-data 26306  0.0  0.0   4008    12 ?        D    Nov05   0:00 ./2.6.37
www-data 26373  0.0  0.0   4008    12 ?        D    Nov05   0:00 ./n2
www-data 26378  0.0  0.0   4008    12 ?        D    Nov05   0:00 ./n2

This is output of ps axl | awk '$10 ~ /D/'for a little more info.

这是ps axl | awk '$10 ~ /D/'更多信息的输出 。

0    33 22851     1  20   0      0     0 econet D    ?          0:00 [2637.64]
1    33 26306     1  20   0   4008    12 ec_dev D    ?          0:00 ./2.6.37
1    33 26373     1  20   0   4008    12 ec_dev D    ?          0:00 ./n2
1    33 26378     1  20   0   4008    12 ec_dev D    ?          0:00 ./n2

Is there a way to kill these? Does having processes in this state when rebooting cause any issues?

有没有办法杀死这些?重新启动时处于此状态的进程是否会导致任何问题?

采纳答案by Deepthought

This is the dreaded un-interruptible (TASK_UNINTERRUPTIBLE) state of a process. This is the state where the process doesn't react to signals until what it started to wait for, gets done. Unfortunately it is a necessary evil. See hereand here What is an uninterruptable process?.

这是进程可怕的不可中断 (TASK_UNINTERRUPTIBLE) 状态。在这种状态下,进程不会对信号做出反应,直到它开始等待的事情完成。不幸的是,这是一种必要的邪恶。请参阅此处和此处什么是不间断进程?.

My answer is to reboot the system.
Do rebooting cause any issues ?
Hard to tell, it may it may not. The process which is in the D state may have to do some crucial updates which it wont if you reboot.
If you really cant afford to reboot, try to find the disk on which the process is waiting and see if the disk is working fine by opening, closing, reading/writing into it

我的答案是重新启动系统。
重新启动会导致任何问题吗?
很难说,可能不会。处于 D 状态的进程可能必须进行一些重要的更新,如果您重新启动就不会这样做。
如果您实在负担不起重新启动的费用,请尝试通过打开、关闭、读/写来找到进程正在等待的磁盘,并查看该磁盘是否工作正常

回答by jim mcnamara

No - you cannot kill them, period. kill -9does not work either. And it is not kernel bug, it is by design. All signals are blocked until those processes leave the D state. They either leave the D state or the system gets rebooted. No, rebooting does not have any problem with these guys.

不 - 你不能杀死他们,期间。kill -9也不起作用。这不是内核错误,而是设计使然。所有信号都被阻塞,直到这些进程离开 D 状态。他们要么离开 D 状态,要么系统重新启动。不,这些家伙重新启动没有任何问题。

The usual culprits for this kind of problem are removable media devices like a cdrom. The device may be defective or somebody found a way to do something stupid.

此类问题的常见罪魁祸首是可移动媒体设备,如 cdrom。设备可能有缺陷,或者有人找到了做一些愚蠢事情的方法。