Thursday, February 23, 2017
What is D state process and how to check ? And what is the impact of it ?
To check the d state prcoess
#ps axl | awk '$10 ~ /D/'
D state occurs when the process is in uninterruptible sleep. This state is bad, because you can't do anything with the process in D state. Fortunately, process normally remains in such state not for so long. But if you have a heap of D state processes then some logic in system is disrupt. If that is happening, the very important thing is to determine where this unlucky sleep occurs. It is easy to do with ps command with l option. WCHAN column shows the name of the kernel function where the process is sleeping:
State D means uninterruptible sleep, which usually means IO. When the IO completes the process will change state. If you think a specific process is hung you can truss or strace it to see what it is doing. i.e.
strace -p <pid of process>
If it does nothing for a long time it is more than likely stuck.
It may nothing to do with which disk folder.
The D state process effect cpu/processor scheduling.
Theoretically, D state still occupying cpu/processor resources.
So if too many D state processes, the cpus are busy on scheduling and re-scheduling (that is why we see high system load).
So the result could be unpredictable.
How to clear D-state process ?
D-state process is nothing but uninterruptible sleep. When doing IO, the process is locked as uninterruptible so the data will not be corrupted. When IO finished, the process will not be D-sate
But for some reason the IO could not be finished or hung, then the process may stick in D. in this cases we need to reboot the server to clear D-state process.