You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
+1 I am seeing gorouting leaks as well. I have seen my Goroutines count go up to 10,000 once a week with. @e-max do you have instructions on how you got the data you did?
nm, found it go tool pprof http://localhost:4343/debug/pprof/profile
when docker is run in debug mode
I think I've found leakage - in pkg/ioutils/readers.go:bufReader. On massive client reads much slower than output comes (I used yes <long string> for reproducing) and bufReader repeatedly growing internal buffer, which causes memory leaks.
Have no idea what to do now, removing bufReader layer can reduce leak, but not fix it entirely.
Hey,
we're running into a potential docker memory leak situation here and this is the most recent open / potentially relevant issue i found - is there any way to try and see if my situation matches what you guys are describing? e.g based on pprof heap output ?
@LK4D4 thanks. since i'm running all my containers by way of an upstart script I don't typically use -d, any good way to interoperate -d and having the container ran via upstart? e.g I guess i could run 'docker run -d', and then try upstart's "expect fork"/"expect daemon" stanza?
@adamhadani Main problem that all forks is in daemon, not in client. I know nothing about upstart, but for openrc for example it is possible to write init script which will be based on --cidfile of docker container. Also, docker wait can be useful, but I don't know how to handle stop with it.
@jszwedko Yeah, I know guys, this is pretty bad thing. I can suggest for now redirect your logs to syslog and try to keep stdout/stderr clean. We'll try to reduce leak in next release.
Thanks @LK4D4. We were able to mitigate it for now by reducing the log volume.
We could log directly to syslog, but we tend to prefer the approach of having the application log to stdout/stderr and let the supervising process decide what to do with the output (e.g. log to file, pipe to logger, etc).
When I docker run -d a container based on the following Dockerfile:
FROM busybox
CMD whiletrue;doecho -n =;done;
it doesn't take very long for an out of memory crash.
Running a version that does print a newline on each row seems to drastically reduce the memory footprint. I'm suspecting this has something to do with stdout being line buffered on a terminal.
Docker is started via Upstart and thus recovered, alas the running containers have died.
Actually, now you mention it, rancher/agent:v0.7.9 is logging an awful lot. And these are running on 1.6.2. I'll try again with 1.7.0 and see how they do being left for a few days.
If there's anything else I can provide, let me know.
@adamkdean Can you tell me what logging driver is being used, please? I haven't used rancher so far and I'm not sure what logging driver it's using. How many containers where you running?
Docker 1.6.2 has memory usage problems related to logging and it'll have these problems forever.
@unclejack The logs look to be saved to /var/lib/dockers/containers/CID/CID-json.log which makes me think it's using the JSON log driver. Is that right?
FYI I've updated these servers to 1.7.0 now so I'll give that a go. They were running much, they were just for R&D but I'll leave them over the weekend and check them on Monday to see how they're doing.
@adamkdean - yes I believe that's correct. FWIW, we use the default logging driver (JSON) and we have an app that spits a lot of info to standard out. Prior to 1.7.0 we had to restart docker nightly in order to keep memory usage under control. We've had 1.7.0 running for ~7 days now and so far the memory leak issue has vastly improved, maybe resolved.
@jbiel That's positive news then, thanks for the information. It was definitely worrying to come back to a cluster to find the hosts unresponsive when all they were running was the clustering software itself!
Don't know if this is related, but I am suffering from humongous swap usage by Docker, ~780 MB out of 2 GB total currently. Would love to be able to resolve this.
Ran into a similar issue, but while running a container though.
> docker-compose up -d
Recreating test_apiserver_1...
Cannot start container 154e5f72a9b61c1d83a19849d7b3351ae3dff4f4c7ffc646114e88167b1b1a56: [8] System error: fork/exec /usr/bin/docker: cannot allocate memory
> docker --debug info
Containers: 12
Images: 172
Storage Driver: devicemapper
Pool Name: docker-202:1-275034-pool
Pool Blocksize: 65.54 kB
Backing Filesystem: extfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 8.095 GB
Data Space Total: 107.4 GB
Data Space Available: 63.69 GB
Metadata Space Used: 9.552 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.138 GB
Udev Sync Supported: true
Deferred Removal Enabled: false
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.77 (2012-10-15)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.13.0-48-generic
Operating System: Ubuntu 14.04.2 LTS
CPUs: 4
Total Memory: 29.96 GiB
Name: straxco
ID: MHLQ:MNHU:276A:B666:6O2H:UGKC:JMBK:LSR4:JWPW:HWBR:LLWJ:3Q3R
Debug mode (server): false
Debug mode (client): true
File Descriptors: 66
Goroutines: 102
System Time: 2016-02-17T18:15:15.708693282-05:00
EventsListeners: 0
Init SHA1: 32127ad3d10373671bcbdc6706733e7089d9d142
Init Path: /usr/lib/docker.io/dockerinit
Docker Root Dir: /var/lib/docker
WARNING: No swap limit support
ps; the same container was running already. Got the below layer while building an image (Apply Layer) and then was unable to run the container. Looks like it take a while to free up some memory
Activity
anandkumarpatel commentedon Nov 13, 2014
+1 I am seeing gorouting leaks as well. I have seen my Goroutines count go up to 10,000 once a week with.
@e-max do you have instructions on how you got the data you did?
nm, found it
go tool pprof http://localhost:4343/debug/pprof/profilewhen docker is run in debug mode
LK4D4 commentedon Nov 13, 2014
Also, guys you can see line numbers like
--linesor something like this.e-max commentedon Nov 14, 2014
Sure. I'v got something like this:
LK4D4 commentedon Nov 18, 2014
I think I've found leakage - in
pkg/ioutils/readers.go:bufReader. On massive client reads much slower than output comes (I usedyes <long string>for reproducing) andbufReaderrepeatedly growing internal buffer, which causes memory leaks.Have no idea what to do now, removing
bufReaderlayer can reduce leak, but not fix it entirely.adamhadani commentedon Dec 10, 2014
Hey,
we're running into a potential docker memory leak situation here and this is the most recent open / potentially relevant issue i found - is there any way to try and see if my situation matches what you guys are describing? e.g based on pprof heap output ?
LK4D4 commentedon Dec 10, 2014
@adamhadani best way to try is run containers in backgorund (
-d) and see if leak is gone.adamhadani commentedon Dec 11, 2014
@LK4D4 thanks. since i'm running all my containers by way of an upstart script I don't typically use -d, any good way to interoperate -d and having the container ran via upstart? e.g I guess i could run 'docker run -d', and then try upstart's "expect fork"/"expect daemon" stanza?
LK4D4 commentedon Dec 11, 2014
@adamhadani Main problem that all forks is in daemon, not in client. I know nothing about upstart, but for openrc for example it is possible to write init script which will be based on
--cidfileof docker container. Also,docker waitcan be useful, but I don't know how to handlestopwith it.jszwedko commentedon Dec 11, 2014
We are seeing the same issue with log heavy applications. We also use upstart to manage the running container in the foreground.
LK4D4 commentedon Dec 11, 2014
@jszwedko Yeah, I know guys, this is pretty bad thing. I can suggest for now redirect your logs to syslog and try to keep stdout/stderr clean. We'll try to reduce leak in next release.
jszwedko commentedon Dec 11, 2014
Thanks @LK4D4. We were able to mitigate it for now by reducing the log volume.
We could log directly to syslog, but we tend to prefer the approach of having the application log to stdout/stderr and let the supervising process decide what to do with the output (e.g. log to file, pipe to
logger, etc).ernstnaezer commentedon Dec 17, 2014
I might have a simple reproduction scenario.
When I
docker run -da container based on the following Dockerfile:it doesn't take very long for an out of memory crash.
Running a version that does print a
newlineon each row seems to drastically reduce the memory footprint. I'm suspecting this has something to do withstdoutbeing line buffered on a terminal.Docker is started via Upstart and thus recovered, alas the running containers have died.
fatal error: runtime: out of memory goroutine 61 [running]: runtime.throw(0x127cc77) /usr/local/go/src/pkg/runtime/panic.c:520 +0x69 fp=0x7faf0c2679a8 sp=0x7faf0c267990 runtime.SysMap(0xc239980000, 0x6060000, 0x2f00, 0x12ad4d8) /usr/local/go/src/pkg/runtime/mem_linux.c:147 +0x93 fp=0x7faf0c2679d8 sp=0x7faf0c2679a8 runtime.MHeap_SysAlloc(0x12b94c0, 0x6060000) /usr/local/go/src/pkg/runtime/malloc.goc:616 +0x15b fp=0x7faf0c267a30 sp=0x7faf0c2679d8 MHeap_Grow(0x12b94c0, 0x3030) /usr/local/go/src/pkg/runtime/mheap.c:319 +0x5d fp=0x7faf0c267a70 sp=0x7faf0c267a30 MHeap_AllocLocked(0x12b94c0, 0x302e, 0x7faf00000000) /usr/local/go/src/pkg/runtime/mheap.c:222 +0x379 fp=0x7faf0c267ab0 sp=0x7faf0c267a70 runtime.MHeap_Alloc(0x12b94c0, 0x302e, 0x100000000) /usr/local/go/src/pkg/runtime/mheap.c:178 +0x7b fp=0x7faf0c267ad8 sp=0x7faf0c267ab0 largealloc(0x9, 0x7faf0c267b88) /usr/local/go/src/pkg/runtime/malloc.goc:224 +0xa2 fp=0x7faf0c267b20 sp=0x7faf0c267ad8 runtime.mallocgc(0x605c000, 0x0, 0x9) /usr/local/go/src/pkg/runtime/malloc.goc:169 +0xb6 fp=0x7faf0c267b88 sp=0x7faf0c267b20 runtime.stringtoslicebyte(0xc22d928000, 0x605b2c3, 0x0, 0x0, 0x0) /usr/local/go/src/pkg/runtime/string.goc:320 +0x65 fp=0x7faf0c267bb0 sp=0x7faf0c267b88 github.com/docker/docker/pkg/broadcastwriter.(*BroadcastWriter).Write(0xc208207c40, 0xc20821a000, 0x8000, 0x8000, 0x8000, 0x0, 0x0) /go/src/github.com/docker/docker/pkg/broadcastwriter/broadcastwriter.go:54 +0x315 fp=0x7faf0c267e40 sp=0x7faf0c267bb0 io.Copy(0x7faf0e518f08, 0xc208207c40, 0x7faf0e50c3a0, 0xc20803d5e0, 0x60532c3, 0x0, 0x0) /usr/local/go/src/pkg/io/io.go:355 +0x27b fp=0x7faf0c267f08 sp=0x7faf0c267e40 os/exec.func·003(0x0, 0x0) /usr/local/go/src/pkg/os/exec/exec.go:214 +0x7e fp=0x7faf0c267f68 sp=0x7faf0c267f08 os/exec.func·004(0xc20816dbc0) /usr/local/go/src/pkg/os/exec/exec.go:321 +0x2c fp=0x7faf0c267fa0 sp=0x7faf0c267f68 runtime.goexit() /usr/local/go/src/pkg/runtime/proc.c:1445 fp=0x7faf0c267fa8 sp=0x7faf0c267fa0 created by os/exec.(*Cmd).Start /usr/local/go/src/pkg/os/exec/exec.go:322 +0x931system and version information
29 remaining items
adamkdean commentedon Jun 25, 2015
Actually, now you mention it,
rancher/agent:v0.7.9is logging an awful lot. And these are running on1.6.2. I'll try again with1.7.0and see how they do being left for a few days.If there's anything else I can provide, let me know.
unclejack commentedon Jun 25, 2015
@adamkdean Can you tell me what logging driver is being used, please? I haven't used rancher so far and I'm not sure what logging driver it's using. How many containers where you running?
Docker 1.6.2 has memory usage problems related to logging and it'll have these problems forever.
miracle2k commentedon Jun 25, 2015
Note that a couple comments above it was recommended that the syslog driver be used instead of the json log. Has this recommendation changed with 1.7?
unclejack commentedon Jun 25, 2015
@miracle2k Some bugs were discovered in the used syslog package. I'll investigate that as well.
adamkdean commentedon Jun 25, 2015
@unclejack The logs look to be saved to
/var/lib/dockers/containers/CID/CID-json.logwhich makes me think it's using the JSON log driver. Is that right?FYI I've updated these servers to 1.7.0 now so I'll give that a go. They were running much, they were just for R&D but I'll leave them over the weekend and check them on Monday to see how they're doing.
jbiel commentedon Jun 25, 2015
@adamkdean - yes I believe that's correct. FWIW, we use the default logging driver (JSON) and we have an app that spits a lot of info to standard out. Prior to 1.7.0 we had to restart docker nightly in order to keep memory usage under control. We've had 1.7.0 running for ~7 days now and so far the memory leak issue has vastly improved, maybe resolved.
adamkdean commentedon Jun 25, 2015
@jbiel That's positive news then, thanks for the information. It was definitely worrying to come back to a cluster to find the hosts unresponsive when all they were running was the clustering software itself!
chenchun commentedon Jul 17, 2015
@enix , I think we could use ReadLine instead of ReadBytes to fix your case, see #14702
jbiel commentedon Jul 21, 2015
This is 100% fixed for us; no more leaks. 👍
thaJeztah commentedon Jul 21, 2015
thanks for reporting back @jbiel! good to hear
adamkdean commentedon Jul 21, 2015
Not a problem for us either. 100% fixed now.
taraspos commentedon Dec 23, 2015
This issue still present with:
and
Running C endless loop in the container leads to docker crash:
with default logging driver it happens like in 30 seconds, with
--loging-driver=nonedocker crashes after 2-minutes:Also I noticed that Docker daemon not failing if you don't try to run any docker commands. For example:
I'm starting the same C endless loop, and if I try to kill this container in 10 seconds Docker daemon will fail. If I don't it will be still running.
unclejack commentedon Dec 23, 2015
This issue has been fixed on master after the release of Docker 1.9. #17877 has fixed the issue and the fix will be in the next Docker version.
Please try to build Docker from the master branch and try to reproduce the problem.
edit: Please take a look at #18057 as well because it's a related issue.
aknuds1 commentedon Jan 27, 2016
Don't know if this is related, but I am suffering from humongous swap usage by Docker, ~780 MB out of 2 GB total currently. Would love to be able to resolve this.
sundarseswaran commentedon Feb 17, 2016
Ran into a similar issue, but while running a container though.
ps; the same container was running already. Got the below layer while building an image (Apply Layer) and then was unable to run the container. Looks like it take a while to free up some memory
ApplyLayer fork/exec /usr/bin/docker: cannot allocate memory stdout: stderr: