【发布时间】:2013-08-21 23:56:09
【问题描述】:
我有一个 Vagrant 来宾,用于在本地运行 Symfony 2 应用程序以进行开发。一般来说,这工作正常,但是,我经常发现进程锁定在“D+”状态(等待 I/O)。
例如。我尝试运行我的单元测试:
./bin/phpunit -c 应用程序
任务启动,但从不退出。在我看到的进程列表中:
vagrant 3279 0.5 4.9 378440 101132 pts/0 D+ 02:43 0:03 php ./bin/phpunit -c app
任务无法杀死。我需要重新启动 Vagrant 来宾以使其重新恢复。这似乎主要发生在 PHP 命令行应用程序中(但它也是我所做的主要命令行任务,因此可能不相关)。
系统日志报告一个挂起的任务:
Aug 20 03:04:40 precise64 kernel: [ 6240.210396] INFO: task php:3279 blocked for more than 120 seconds.
Aug 20 03:04:40 precise64 kernel: [ 6240.211920] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
Aug 20 03:04:40 precise64 kernel: [ 6240.212843] php D 0000000000000000 0 3279 3091 0x00000004
Aug 20 03:04:40 precise64 kernel: [ 6240.212846] ffff88007aa13c98 0000000000000082 ffff88007aa13c38 ffffffff810830df
Aug 20 03:04:40 precise64 kernel: [ 6240.212849] ffff88007aa13fd8 ffff88007aa13fd8 ffff88007aa13fd8 0000000000013780
Aug 20 03:04:40 precise64 kernel: [ 6240.212851] ffff88007aa9c4d0 ffff880079e596f0 ffff88007aa13c78 ffff88007fc14040
Aug 20 03:04:40 precise64 kernel: [ 6240.212853] Call Trace:
Aug 20 03:04:40 precise64 kernel: [ 6240.212859] [<ffffffff810830df>] ? queue_work+0x1f/0x30
Aug 20 03:04:40 precise64 kernel: [ 6240.212863] [<ffffffff811170e0>] ? __lock_page+0x70/0x70
Aug 20 03:04:40 precise64 kernel: [ 6240.212866] [<ffffffff8165a55f>] schedule+0x3f/0x60
Aug 20 03:04:40 precise64 kernel: [ 6240.212867] [<ffffffff8165a60f>] io_schedule+0x8f/0xd0
Aug 20 03:04:40 precise64 kernel: [ 6240.212869] [<ffffffff811170ee>] sleep_on_page+0xe/0x20
Aug 20 03:04:40 precise64 kernel: [ 6240.212871] [<ffffffff8165ae2f>] __wait_on_bit+0x5f/0x90
Aug 20 03:04:40 precise64 kernel: [ 6240.212873] [<ffffffff81117258>] wait_on_page_bit+0x78/0x80
Aug 20 03:04:40 precise64 kernel: [ 6240.212875] [<ffffffff8108af00>] ? autoremove_wake_function+0x40/0x40
Aug 20 03:04:40 precise64 kernel: [ 6240.212877] [<ffffffff8111736c>] filemap_fdatawait_range+0x10c/0x1a0
Aug 20 03:04:40 precise64 kernel: [ 6240.212882] [<ffffffff81122a01>] ? do_writepages+0x21/0x40
Aug 20 03:04:40 precise64 kernel: [ 6240.212884] [<ffffffff81118da8>] filemap_write_and_wait_range+0x68/0x80
Aug 20 03:04:40 precise64 kernel: [ 6240.212892] [<ffffffffa01269fe>] nfs_file_fsync+0x5e/0x130 [nfs]
Aug 20 03:04:40 precise64 kernel: [ 6240.212896] [<ffffffff811a632b>] vfs_fsync+0x2b/0x40
Aug 20 03:04:40 precise64 kernel: [ 6240.212900] [<ffffffffa01272c3>] nfs_file_flush+0x53/0x80 [nfs]
Aug 20 03:04:40 precise64 kernel: [ 6240.212903] [<ffffffff81175d6f>] filp_close+0x3f/0x90
Aug 20 03:04:40 precise64 kernel: [ 6240.212905] [<ffffffff81175e72>] sys_close+0xb2/0x120
Aug 20 03:04:40 precise64 kernel: [ 6240.212907] [<ffffffff81664a82>] system_call_fastpath+0x16/0x1b`
为了配置盒子,我正在使用以下方式共享一个本地文件夹:
config.vm.synced_folder "/my/local/path.dev", "/var/www", :nfs => true
Vagrant 在 OSX 主机上创建以下 /etc/exports 文件:
# VAGRANT-BEGIN: c7d0c56a-a126-46f5-a293-605bf554bc9a
"/Users/djdrey-local/Sites/oddswop.dev" 192.168.33.101 -mapall=501:20
# VAGRANT-END: c7d0c56a-a126-46f5-a293-605bf554bc9a
流浪客上 nfsstat 的输出
Server rpc stats:
calls badcalls badclnt badauth xdrcall
0 0 0 0 0
Client rpc stats:
calls retrans authrefrsh
87751 0 87751
Client nfs v3:
null getattr setattr lookup access readlink
0 0% 35018 39% 1110 1% 8756 9% 19086 21% 0 0%
read write create mkdir symlink mknod
5100 5% 7059 8% 4603 5% 192 0% 0 0% 0 0%
remove rmdir rename link readdir readdirplus
4962 5% 262 0% 313 0% 0 0% 0 0% 1056 1%
fsstat fsinfo pathconf commit
1 0% 2 0% 1 0% 229 0%
我已使用插件确保来宾添加在来宾上是最新的:vagrant-vbguest
我不确定如何进行调试。我很清楚这是来宾和 Mac OSX 主机之间的 NFS 问题。如果我尝试使用 NFS 管理器在 OSX 上设置 NFS 的调试日志记录,我会在 OSX 中遇到内核崩溃。
还有其他人遇到过类似的问题吗?任何关于前进方向的建议都将不胜感激 - 因为每天多次为客人供电是不可行的。
环境
- OSX 10.8.4
- 流浪者 1.2.7
- Virtualbox 4.2.16
- Vagrant 来宾操作系统:Ubuntu 12.04.2 LTS(GNU/Linux 3.2.0-23-generic x86_64)[precise64.box]
【问题讨论】:
-
你能用 strace 运行 php 进程吗?也许有助于了解正在发生的事情。
-
可能是stackoverflow.com/questions/18085868/… 的副本,您应该阅读问题的答案。它适用于 cifs,但 NFS 是最广为人知的案例(超过 smb/cifs)。其他版本没有这个问题。但是,我认为您不能在 XNU 上选择 NFS 服务器版本(4)。再说一遍:这与我在 CIFS 问题上写的答案相同。在 linux 内核端实现了许多网络文件系统;如果服务器在网络上无法访问,则该进程将成为挂起的任务。
-
@user2284570 使用 Vagrant - 都在同一台机器上。因此 NFS 连接是通过虚拟 NIC 连接到 VirtualBox。我的假设不太可能是连接问题。
-
顾名思义,虚拟机的目标是制作一个如果它们是具有独立硬件的几台物理机。所有网络信息都通过一个虚拟卡(在服务器上),它像任何其他以太网卡一样发出虚拟以太网帧。在这种情况下,通过虚拟机添加为 VM/服务器提供了唯一的例外。网络的唯一例外是又名 Virtual Box 共享文件夹。此外,您的回溯中有一些 NFS 函数,假设您的程序(D 状态)正在等待网络 I/O。请记住,网络故障可能是由软件引起的。
标签: php osx-mountain-lion vagrant