che icon indicating copy to clipboard operation
che copied to clipboard

Terminal keeps opened hundred of bash processes.

Open skryzhny opened this issue 9 years ago • 9 comments

I got monitoring alert about too many processes opened on some of our nodes. It was bash processes spawned by terminal

centos   11194  0.0  0.0   4504   156 ?        Ss   Jan08   0:00  |   |   \_ /bin/sh -c trap '[ -z "$(jobs -p)" ] || kill $(jobs -p); [ -e /tmp/docker-exec-3424.pid ] && rm /tmp/docker-exec-3424.pid' EXIT; echo $$>/tmp/docker-exec-3424.pi
centos   11273  0.0  0.2 124408 70824 ?        Sl   Jan08   1:03  |   |       \_ /home/user/che/terminal/che-websocket-terminal -addr :4411 -cmd /bin/bash -static /home/user/che/terminal/
centos   12573  0.0  0.0  19904   372 pts/0    Ss+  Jan08   0:00  |   |           \_ /bin/bash
centos   19634  0.0  0.0  19900   464 pts/1    Ss+  Jan08   0:00  |   |           \_ /bin/bash
centos   21406  0.0  0.0  19900   468 pts/2    Ss+  Jan08   0:00  |   |           \_ /bin/bash
centos   22738  0.0  0.0  19900   732 ?        Ss+  Jan08   0:00  |   |           \_ /bin/bash
centos   24842  0.0  0.0  19900   248 ?        Ss+  Jan08   0:00  |   |           \_ /bin/bash
centos   25634  0.0  0.0  19900   252 ?        Ss+  Jan08   0:00  |   |           \_ /bin/bash
centos   28721  0.0  0.0  19900   248 ?        Ss+  Jan08   0:00  |   |           \_ /bin/bash
centos   30432  0.0  0.0  19900   248 ?        Ss+  Jan08   0:00  |   |           \_ /bin/bash
centos   31573  0.0  0.0  19900   732 ?        Ss+  Jan08   0:00  |   |           \_ /bin/bash

Inspecting shows that it was more than 600 bash processes.

# ps ax | grep -c [b]ash 
614

I think we need to close bash processes spawned by terminal that we don't use.

Reproduction Steps: Probably just hit refresh button.

Che version: 5.0.0-M8

OS and version:
Centos 7.3

Docker version: 1.11.1

skryzhny avatar Jan 10 '17 08:01 skryzhny

We didn't implement yet reconnect to concrete already running terminal process. For now when websocket connection abnormal closed(or closed after refresh browser page with IDE) we reconnect to new terminal process and old lost terminal process is unused. So we need rework our client and server to add ability save unique terminal process identifier (for example some id) and reconnect to this terminal process by this identifier without creation new terminal process. I think this important - reusing terminal processes and we can thinking about fix this bug after completion xtermjs epic.

AndrienkoAleksandr avatar Jan 10 '17 09:01 AndrienkoAleksandr

Depends on implementing of xterm terminal.

vkuznyetsov avatar Jan 16 '17 14:01 vkuznyetsov

@skryzhny What is the impact on performance or stability of server?

JamesDrummond avatar Jan 24 '17 07:01 JamesDrummond

@JamesDrummond Well, it indirectly affect stability of servers (WorkspaceNodes). It triggers monitoring system warning and after that it shows warning till the stop of workspace. So I'm forced to manually recheck cause of that warning in some intervals like once in 20 minutes. Or I may consider monitoring system's warning related to this issue and stop checking, in this case I may miss real problem with server, because warning already triggered. Surely I'm want to avoid such noise in monitoring systems.

skryzhny avatar Apr 19 '17 14:04 skryzhny

For restore terminal we need client api for restore state. In the xterm.js such api planned and in development progress https://github.com/sourcelair/xterm.js/issues/595, but not completed yet https://github.com/sourcelair/xterm.js/pull/613. So we need await until it will be implemented.

AndrienkoAleksandr avatar Apr 26 '17 07:04 AndrienkoAleksandr

@AndrienkoAleksandr is this issue up to date for the current version of Che?

skabashnyuk avatar Jun 27 '18 05:06 skabashnyuk

Yes. To restore terminal output can be implemented ring buffer, something like here: https://github.com/eclipse/che-theia-terminal-plugin/pull/1/files#diff-4437984fdbb9bc43cbb06e64cacc6e3d

AndrienkoAleksandr avatar Jun 27 '18 07:06 AndrienkoAleksandr

Xterm.js doesn't implemented api to restore, issue was freezed. But we can do it with help server side.

AndrienkoAleksandr avatar Jun 27 '18 07:06 AndrienkoAleksandr

Not relevant anymore. Please consider opening a new issue if you think it is up to date.

skabashnyuk avatar Aug 08 '19 11:08 skabashnyuk