Lustre文件锁问题
来源:互联网 发布:淘宝代销商品怎么下单 编辑:程序博客网 时间:2024/04/24 18:37
问题现象:进程读取文件Hang,单进程读取正常,多个进程同时读取出现Hang,多个进程若在同一台服务器上提交,也可正常运行。
问题分析:从现象来看,分析可能产生的原因。
1、linux下同时打开文件数达到最大值?
2、mount挂载时缺少相关参数导致?
第一个问题比较好排查,ulimit -a即可查看当前配置的open files大小,再通过lsof / |wc -l即可统计当前打开的文件数量,通过查看当前系统打开的文件数量还远远未达到限制。
第二个问题需要做几次验证测试,lustre挂载命令中有个参数localflock、flock、noflock,集群当前客户端挂载统一使用的是localflock,于是将flock、noflock分别添加进行测试
,测试结果发现localflock和flock效果相同,对我们的任务没什么影响,如果使用noflock,不加锁,任务提交会失败。
至此,设想的两种可能都被排除。
为了更深层次了解程序运行状况,使用gdb进行调试,查看程序到底是hang在了什么位置:
正如所预料的,有一个CPU使用率为0的进程,卡在申请锁上:
(gdb) bt
#0 0x0000003a3b00e938 in fcntl () from /lib64/libpthread.so.0
#1 0x00002b04316a7d95 in mdb_env_excl_lock (env=0x60dc830, lpath=Unhandled dwarf expression opcode 0xf3
) at mdb.c:3744
#2 mdb_env_setup_locks (env=0x60dc830, lpath=Unhandled dwarf expression opcode 0xf3
) at mdb.c:3908
#3 0x00002b04316a99eb in mdb_env_open (env=0x60dc830, path=Unhandled dwarf expression opcode 0xf3
) at mdb.c:4165
#4 0x00002b042ac41d43 in caffe::db::LMDB::Open(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, caffe::db::Mode) () from /lustre/face/zywu/zywu/caffe-Progress/.build_release/tools/../lib/libcaffe-nv.so.0
#5 0x00002b042ac5e770 in caffe::ChunkReader::ChunkReader(caffe::ReaderParameter const&) ()
from /lustre/face/zywu/zywu/caffe-Progress/.build_release/tools/../lib/libcaffe-nv.so.0
#6 0x00002b042ad1a5f5 in caffe::GeneralDataLayer<float>::DataLayerSetUp(std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&, std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&) ()
from /lustre/face/zywu/zywu/caffe-Progress/.build_release/tools/../lib/libcaffe-nv.so.0
#7 0x00002b042ad32128 in caffe::BaseDataLayer<float>::LayerSetUp(std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&, std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&) ()
from /lustre/face/zywu/zywu/caffe-Progress/.build_release/tools/../lib/libcaffe-nv.so.0
#8 0x00002b042ad3218e in caffe::BasePrefetchingDataLayer<float>::LayerSetUp(std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&, std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&) ()
from /lustre/face/zywu/zywu/caffe-Progress/.build_release/tools/../lib/libcaffe-nv.so.0
#9 0x00002b042ac7a594 in caffe::Net<float>::Init(caffe::NetParameter const&) ()
from /lustre/face/zywu/zywu/caffe-Progress/.build_release/tools/../lib/libcaffe-nv.so.0
#10 0x00002b042ac7d182 in caffe::Net<float>::Net(caffe::NetParameter const&) ()
from /lustre/face/zywu/zywu/caffe-Progress/.build_release/tools/../lib/libcaffe-nv.so.0
#11 0x00002b042ad593a5 in caffe::Solver<float>::InitTrainNet() ()
from /lustre/face/zywu/zywu/caffe-Progress/.build_release/tools/../lib/libcaffe-nv.so.0
#12 0x00002b042ad5c3cf in caffe::Solver<float>::Init(caffe::SolverParameter const&) ()
from /lustre/face/zywu/zywu/caffe-Progress/.build_release/tools/../lib/libcaffe-nv.so.0
#13 0x00002b042ad5c874 in caffe::Solver<float>::Solver(caffe::SolverParameter const&) ()
from /lustre/face/zywu/zywu/caffe-Progress/.build_release/tools/../lib/libcaffe-nv.so.0
#14 0x0000000000412156 in caffe::SGDSolver<float>::SGDSolver(caffe::SolverParameter const&) ()
#15 0x00000000004122f8 in caffe::Solver<float>* caffe::GetSolver<float>(caffe::SolverParameter const&) ()
#16 0x000000000040d83e in train() ()
#17 0x000000000040f808 in main ()
LMDB的相关代码为:
struct flock lock_info;
memset((void *)&lock_info, 0, sizeof(lock_info));
lock_info.l_type = F_WRLCK;
lock_info.l_whence = SEEK_SET;
lock_info.l_start = 0;
lock_info.l_len = 1;
while ((rc = fcntl(env->me_lfd, F_SETLK, &lock_info)) &&
(rc = ErrCode()) == EINTR) ;
if (!rc) {
*excl = 1;
} else
# ifndef MDB_USE_POSIX_MUTEX
if (*excl < 0) /* always true when MDB_USE_POSIX_MUTEX */
# endif
{
lock_info.l_type = F_RDLCK;
while ((rc = fcntl(env->me_lfd, F_SETLKW, &lock_info)) &&
(rc = ErrCode()) == EINTR) ;
if (rc == 0)
*excl = 0;
}
因为lmdb库里面,调用fcntl,对这个文件上锁了,使用了排他锁,所以同时只能有一个程序读取LMDB数据库文件。
解决方法:修改程序,将mdb_env_open函数中传参数MDB_NOLOCK,这样就不会对文件上锁了。
0 0
- Lustre文件锁问题
- lustre spec示例文件
- Lustre文件系统分布式锁
- 云计算技术研习:Lustre文件系统处理大文件
- 深入理解Lustre文件系统-第4篇 LDLM:Lustre分布式锁管理
- 配置lustre和rsh时遇到的小问题
- 深入理解Lustre文件系统-第5篇 LDLM:锁管理者
- Lustre Recovery
- Lustre资源
- lustre安装
- lustre升级
- 【机器管理问题记录】普通用户访问挂载lustre内容权限限制
- Lustre(待修正)
- cfs之lustre实验
- Lustre 2.0 Installation notes
- 内核和lustre补丁
- Lustre 性能测试方法
- 如何启用Lustre Quota
- Git Reference---Basic Snapshotting
- NDK jni 加载静态库
- 【jQuery】使用one()方法绑定元素的一次性事件
- ActivatePowerMode插件,xcode版本
- Python学习二:Django Web入门
- Lustre文件锁问题
- Java多线程总结(5)— 原子性、可见性、有序性和并发库的原子性操作
- 用boost中的property_tree实现配置文件
- Android分区解释
- 按钮设置监听
- Android内存优化杂谈
- hibernate3.0执行存储过程
- 模块化Activity-Fragment
- 如何将ubuntu中的顶部任务栏变成半透明