Skip to content

Machine stuck in iowait using device mapper #3280

Closed

Description

@pwaller

I've made a public container called scraperwiki/go using hack/dind and the principles in this Dockerfile.

The image works on my local machine. It does not work on EC2, I get the behaviour described below. The main difference I'm aware of is that my local machine has AUFS installed where EC2 does not.

I get a prompt by running docker run -t -i -privileged scraperwiki/go dind bash.

When I try to start docker -d &, I get the following output, then nothing:

[/var/lib/docker|2621c420] +job initapi()
[/var/lib/docker|2621c420.initapi()] Creating server

If I subsequently try to use it, it freezes. The whole machine goes into 100% IO wait for longer than 5 minutes. I observe a mkfs.ext4 running, and if I strace it (and wait long enough), I observe:

lseek(3, 4508418048, SEEK_SET)          = 4508418048
write(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
32768) = 32768
lseek(3, 4508450816, SEEK_SET)          = 4508450816
write(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 
32768

And nothing more, just those two lines. I've waited ten minutes and nothing more has appeared. If I try to run anything (e.g, "ps aux") inside the dind container, it freezes.

After all of the above, the host machine has 1.4GB of free disk space.

/cc @jpetazzo

Activity

  1. crosbymichael commented on Dec 19, 2013

    @crosbymichael
    Contributor

    @pwaller FYI @jpetazzo is gone until next year

  2. pwaller commented on Dec 19, 2013

    @pwaller
    ContributorAuthor

    @crosbymichael thanks. I'm off for the evening. Any chance I'll find help anywhere tomorrow?

    The next thing I'll try is setting up AUFS. Will docker use it by default if it is available?

  3. crosbymichael commented on Dec 19, 2013

    @crosbymichael
    Contributor

    Yes docker will try to use aufs by default. What you are seeing is device mapper setting up it's sparse files

  4. pwaller commented on Dec 20, 2013

    @pwaller
    ContributorAuthor

    How might I understand why the device mapper is being so slow?

  5. pwaller commented on Jan 6, 2014

    @pwaller
    ContributorAuthor

    Followup: At the time, I gave up on this for the holidays. Now that I've come back the machine is out of disk space and du -sch reports that /var/lib/docker/devicemapper is using 29GB of disk space. (It's an 8GB disk in total).

    What is going on, and how to fix it? If I don't get a response by the time this post is 18 hours old I'll delete the files and setup aufs.

  6. tianon commented on Jan 6, 2014

    @tianon
    Member

    Try adding -x to your du -sch (ie, du -schx) - that will stop it from traversing down inside mount points, which should make it give you a more accurate accounting of actual space used without duplicating layers many times.

  7. pwaller commented on Jan 6, 2014

    @pwaller
    ContributorAuthor

    Thanks, that reports 4.5GB. @tianon, if I delete the contents of devicemapper will I destroy information needed for debugging? I need to try AUFS so that I can proceed with the current project.

  8. tianon commented on Jan 6, 2014

    @tianon
    Member

    I can't speak for the core guys (who'd be the ones trying to help debug this), but I think they'd need to try to replicate it reliably to debug it properly.

  9. unclejack commented on Jan 21, 2014

    @unclejack
    Contributor

    @pwaller Can you provide the output of docker version and docker info, please? Knowing the Linux distribution you're using would help as well.

  10. pwaller commented on Jan 21, 2014

    @pwaller
    ContributorAuthor

    @unclejack it's ubuntu 13.10 and it was a fresh machine with docker ~0.7.0 or whatever the latest version when I posted the issue. I have since installed aufs on the machine and completely sidestepped the problem.

  11. unclejack commented on Jan 21, 2014

    @unclejack
    Contributor

    @pwaller I've tried to reproduce this and couldn't reproduce it in any way. I'm not seeing any of the stalls and any strange behavior. It might have been caused by some problems with those particular setups.

    I'll close this issue since I can't reproduce it. If anyone runs into a similar problem, please feel free to comment on this issue and provide all the steps to help us reproduce the problem.

  12. djmaze commented on Jan 22, 2014

    @djmaze
    Contributor

    Having the same problem, albeit on a quite new, unsupported system: Arch Linux ARM on an Odroid U3, which is an armv7h platform. But docker is now available on ARM and reportedly works on the Raspberry Pi already. The system is fully updated with the latest packages from the ARM repository.

    Not trying any dind stuff. The problem already occurs when trying to start the docker daemon:

    $ sudo systemctl start docker
    $ sudo systemctl status docker
    docker.service - Docker Application Container Engine
       Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled)
       Active: active (running) since Tue 2014-01-21 16:31:30 MST; 22min ago
         Docs: http://docs.docker.io
      Process: 318 ExecStartPre=/bin/mount --make-rprivate / (code=exited, status=0/SUCCESS)
     Main PID: 321 (docker)
       CGroup: /system.slice/docker.service
               ├─321 /usr/bin/docker -d
               └─347 mkfs.ext4 -E discard,lazy_itable_init=0,lazy_journal_init=0 /dev/mapper/docker-179:3-131-base
    
    Jan 21 16:31:30 alarm systemd[1]: Started Docker Application Container Engine.
    Jan 21 16:31:30 alarm docker[321]: [/var/lib/docker|e65fdae1] +job initapi()
    Jan 21 16:31:30 alarm docker[321]: [/var/lib/docker|e65fdae1.initapi()] Creating server

    This is as far as it gets. The mkfs.ext4 process keeps running and very slowly (about 1MB / min) fills up the partition mounted at /var/lib/docker. (I tried with ext4 and xfs.) strace output looks like @pwaller's, printing some of those lines every few minutes. A couple of minutes later, there are no traces anymore. The devicemapper directory is getting bigger still.

    I am getting kernel "task hung" errors when trying to kill the mkfs process. Only a hard reboot helps to get rid of it.

    One hour passed, still waiting for the mkfs to complete. Problem occurs with either 0.7.2 or 0.7.6.

    $ docker version
    Client version: 0.7.6
    Go version (client): go1.2
    Git commit (client): bc3b2ec-dirty
    2014/01/21 16:54:39 dial unix /var/run/docker.sock: no such file or directory

    Is there anything else I can do to help debug this?

  13. unclejack commented on Jan 22, 2014

    @unclejack
    Contributor

    @djmaze What kernel version are you running on that ARM board?
    It sounds like your little ARM board is running into problems when it's formatting the ext4 devicemapper volumes.

    I'm not sure what kind of storage you're using on that board, but you might be running into some kind of problems caused by the flash being too slow, the kernel being heavily modified or old, or a combination of both.

  14. djmaze commented on Jan 22, 2014

    @djmaze
    Contributor

    @unclejack: The kernel is Linux alarm 3.8.13.14-1-ARCH #3 SMP PREEMPT Mon Dec 30 10:03:31 MST 2013 armv7l GNU/Linux, which is a heavily modified version. The storage is a eMMC card, which ought to be at least as fast as a standard hard drive. (And, after some testing, it really seems to be.)

    So it looks like I should try to do some isolated devicemapper testing on that device? Was just wondering because my system was showing the exact same symptoms as @pwaller's.

  15. 39 remaining items

  16. blalor commented on Apr 2, 2014

    @blalor

    @alexlarsson I just emailed Mike about that commit before realizing you work for RH, too. :-) Do you know if that commit will be making it into the kernel for RHEL 6.5 any time soon?

  17. alexlarsson commented on Apr 3, 2014

    @alexlarsson
    Contributor

    @blalor I have no idea unfortunately

  18. unclejack commented on Jun 18, 2014

    @unclejack
    Contributor

    @alexlarsson Given the optimizations which went into Docker since this issue was created, do you think this can still be a problem?

  19. alexlarsson commented on Jun 19, 2014

    @alexlarsson
    Contributor

    No, there are still a bunch of weirdness wrt discard. I'd like to avoid the discard workaround on image remove we have, that speeds up deletes many times (try with --storage-opt dm.blkdiscard=false).

  20. daniel-garcia commented on Jul 17, 2014

    @daniel-garcia
    Contributor

    Also seeing this using EC2 ubuntu 14.04 image:

    root@ip-10-111-2-76:/etc/init# uname  -a
    Linux ip-10-111-2-76 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
    root@ip-10-111-2-76:/etc/init# docker info
    Containers: 157
    Images: 61
    Storage Driver: devicemapper
     Pool Name: docker-202:16-1048826-pool
     Data file: /var/lib/docker/devicemapper/devicemapper/data
     Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
     Data Space Used: 7320.8 Mb
     Data Space Total: 102400.0 Mb
     Metadata Space Used: 14.3 Mb
     Metadata Space Total: 2048.0 Mb
    Execution Driver: native-0.2
    Kernel Version: 3.13.0-24-generic
    

    The "--storage-opt dm.blkdiscard=false" option brought down the load average from 60 to 8 (for our application. We launch about 40 containers.

  21. jbiel commented on Aug 21, 2014

    @jbiel
    Contributor

    I've also seen this on Arch Linux on EC2 using an AMI from here: https://www.uplinklabs.net/projects/arch-linux-on-ec2/ The IO workload is quite intense while doing anything with the containers.

    # docker info
    Containers: 1
    Images: 43
    Storage Driver: devicemapper
     Pool Name: docker-202:1-278932-pool
     Data file: /var/lib/docker/devicemapper/devicemapper/data
     Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
     Data Space Used: 2126.2 Mb
     Data Space Total: 102400.0 Mb
     Metadata Space Used: 3.0 Mb
     Metadata Space Total: 2048.0 Mb
    Execution Driver: native-0.2
    Kernel Version: 3.14.17-1-ec2-lts
    
    # docker version
    Client version: 1.1.2
    Client API version: 1.13
    Go version (client): go1.3
    Git commit (client): d84a070
    Server version: 1.1.2
    Server API version: 1.13
    Go version (server): go1.3
    Git commit (server): d84a070
    

    Regarding the same issue on Ubuntu 14.04, install the linux-image-extra-$version-generic package for your kernel to enable AUFS.

  22. added a commit that references this issue on Aug 31, 2014
  23. added a commit that references this issue on Oct 2, 2014
  24. unclejack commented on Dec 19, 2014

    @unclejack
    Contributor

    Is anyone still running into this problem?

  25. pwaller commented on Dec 20, 2014

    @pwaller
    ContributorAuthor

    I'm the original reporter. I haven't seen this issue in many months, but then I haven't been using the device mapper very much either.

  26. crosbymichael commented on Feb 12, 2015

    @crosbymichael
    Contributor

    Lets close this for now as the comments above and if anyone is still having the issue please open a new report with your specific problem and configuration.

  27. fiorix commented on Nov 6, 2015

    @fiorix

    I'm still having this problem using device mapper on kvm virtual machines, it's running very slow. By looking at the current master branch I see lazy_itable_init=0 (mentioned by @djmaze) is still in the code:

    docker $ grep -ri lazy_itable_init=0 *
    daemon/graphdriver/devmapper/deviceset.go:      err = exec.Command("mkfs.ext4", append([]string{"-E", "nodiscard,lazy_itable_init=0,lazy_journal_init=0"}, args...)...).Run()
    daemon/graphdriver/devmapper/deviceset.go:          err = exec.Command("mkfs.ext4", append([]string{"-E", "nodiscard,lazy_itable_init=0"}, args...)...).Run()
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions