Session worker leaks the memory and fills up the logs with sequence number errors
My EC2 instance (Ubuntu 16.04.5 on t3.medium) has the AWS SSM agent v2.3.274.0.
I recently started using aws ssm start-session command with session-manager-plugin (v1.0.37.0) with AWS CLI (v1.16.71) on macOS Mojave.
I got warning messages from my cloud monitoring service about abnormality of the memory pressure, and discovered that two ssm agent's session worker processes ate about 600 MiB of memory in total and spitting out the infinite stream of logs like below:
2018-12-08 14:42:19 INFO [ssm-session-worker] [xxx-06beb21526e90bdd6] [DataBackend] [pluginName=Standard_Stream] Unexpected sequence message received. Received Sequence Number: %!s(int64=1529591). Expected Sequence Number: %!s(int64=152089)
2018-12-08 14:42:19 INFO [ssm-session-worker] [xxx-06beb21526e90bdd6] [DataBackend] [pluginName=Standard_Stream] Unexpected sequence message received. Received Sequence Number: %!s(int64=1529592). Expected Sequence Number: %!s(int64=152089)
2018-12-08 14:42:19 INFO [ssm-session-worker] [xxx-06beb21526e90bdd6] [DataBackend] [pluginName=Standard_Stream] Unexpected sequence message received. Received Sequence Number: %!s(int64=1529593). Expected Sequence Number: %!s(int64=152089)
2018-12-08 14:42:19 INFO [ssm-session-worker] [xxx-06beb21526e90bdd6] [DataBackend] [pluginName=Standard_Stream] Unexpected sequence message received. Received Sequence Number: %!s(int64=1529594). Expected Sequence Number: %!s(int64=152089)
2018-12-08 14:42:19 INFO [ssm-session-worker] [xxx-06beb21526e90bdd6] [DataBackend] [pluginName=Standard_Stream] Unexpected sequence message received. Received Sequence Number: %!s(int64=1529595). Expected Sequence Number: %!s(int64=152089)
2018-12-08 14:42:19 INFO [ssm-session-worker] [xxx-06beb21526e90bdd6] [DataBackend] [pluginName=Standard_Stream] Unexpected sequence message received. Received Sequence Number: %!s(int64=1529596). Expected Sequence Number: %!s(int64=152089)
(I've masked the username as xxx)
The logs were never stopping -- 5 log-rotated files with 30 MiB size limits were almost full. Fortunately they consumed only about 2~4% of total CPU time in the system. I had to manually kill those processes to get back the normal operation status.
Though, the session manager page in the AWS management console still shows another session xxx-0b94371bdc404b84c as "terminating..." with a rotating spinner after manual termination, while the session xxx-06beb21526e90bdd6 is shown as terminated.
I'm not sure what triggered this, but it seems like to be a bug in the ssm agent.
I found what triggers this: Pressing Ctrl+C to terminate remote commands (e.g., tail -f) causes the session manager client to terminate as well, and then the session worker process remains alive with spitting out the infinite sequence number errors. In the client side (my local shell where I executed awscli), a background session manager plugin process infinitely prints the last character I typed to the session, forcing me to close the shell.
I think the session manager client should pass Ctrl+C (i.e., SIGINT) transparently to the remote session while the session is connected.
Thank you for the feedback! We were not able to reproduce the issue and was hoping you can help us understand the repro steps better. To start with, which terminal are you using for this scenario? Is this a consistent repro in your setup?
I'm using iTerm 3.2.6 and my local shell is zsh installed via homebrew, running under TERM=xterm-256color.
It sometimes does not happen but mostly does (more than 50% chances).
Maybe this issue could be eliminated/workarounded when AWS Session Manager begins to support local SSH clients as promised at the last part in the blog announcing the new sessino manager. But still, I believe that Ctrl+C (SIGINT) should gracefully terminate the session even in the current status.
Thank you for the info. We are still not able to reproduce this issue on our end. Could you please let us know the exact command to reproduce this issue. Also, it would be helpful to debug further if you can provide ssm agent logs and plugin (debug) logs when the issue happens.
Plugin logs can be enabled by following https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html#install-plugin-configure-logs
Additionally, we made some improvements in ssm agent as well as plugin. Could you please upgrade both and let us know if this issue still happens.
Hi @achimnol , I'm going to close this issue. Feel free to open up another issue if you are still running into issues. Thanks!